Results 1 to 4 of 4

Thread: How to change some files backgroundcolors

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    tokyo Japan
    Posts
    5
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default How to change some files backgroundcolors

    I want to change the backgroundcolor, that some files in treeview.

    but, I don't know how to change.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to change some files backgroundcolors

    Qt Code:
    1. QVariant MyTreeModel::data(const QModelIndex &index, int role) const
    2. {
    3. ....
    4. if (role == Qt::BackgroundRole)
    5. return QColor(lightGray);
    6. ....
    7. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. The following user says thank you to spirit for this useful post:

    tkms (15th December 2008)

  4. #3
    Join Date
    Dec 2008
    Location
    tokyo Japan
    Posts
    5
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Re: How to change some files backgroundcolors

    I want to add a color to the parent of the file which I chose. how should I do it?
    Last edited by tkms; 17th December 2008 at 05:35.

  5. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to change some files backgroundcolors

    use this method
    Qt Code:
    1. bool QAbstractItemModel::setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole )
    To copy to clipboard, switch view to plain text mode 
    i.e. in you case
    Qt Code:
    1. ...
    2. QVariant v = QColor(Qt::red);
    3. myModel->setData(index, v, Qt::BackgroundRole);
    4. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. The following user says thank you to spirit for this useful post:

    tkms (17th December 2008)

Similar Threads

  1. visual studio project files - adding extra files
    By luf in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2008, 21:05
  2. Replies: 5
    Last Post: 22nd September 2006, 08:04
  3. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.