Results 1 to 3 of 3

Thread: Styling a branch in QTreeView depending on an additional property

  1. #1
    Join Date
    Jul 2008
    Posts
    16
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Styling a branch in QTreeView depending on an additional property

    Hello,

    I’m using a QTreeView where the branches can be updated seperately. Anytime, a branche updates, it should not be possible to expand the branch, so I want to replace the + or arrow icon with something else. My first approach was to use a user-defined property on the ItemDelegate, however this only works with the item’s icon and not with the branch’s.

    So, I’d like to know if it is possible to make the style used for a branch icon dependent on an additional property. I know, that it is possible with style sheets to use properties like active and children and so on, but can I define some other property for the branch without cloning all but one line of QTreeView::drawBranches? (Unfortunately the extraFlags variable used inside drawBranches is not directly assignable from the outside, and on the other hand, drawPrimitive does not take any information about the QModelIndex but maybe there is some trick to get this working.)

    /rike

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Styling a branch in QTreeView depending on an additional property

    You can draw the branch yourself. It's done by reimplementing QTreeView::drawRow() as far as I remember.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2008
    Posts
    16
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Styling a branch in QTreeView depending on an additional property

    I think, I’ve found some kind of work around to this problem. Since QTreeView::drawBranches() takes the QModelIndex as an argument, I can subclass this method and then draw the icon inside that, if needed. It still needs a bit of fine-tuning, though.

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.