Results 1 to 3 of 3

Thread: QTreeView -- Alternating Row Colors Oddity

  1. #1
    Join Date
    Apr 2007
    Location
    United States
    Posts
    17
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Question QTreeView -- Alternating Row Colors Oddity

    I have a QTreeView displaying data from a custom model. Basically i turn on alternating row colors to make everything readable. However the alternating row colors do not paint all colums, only columns with data or where a model item has been created. Is there anyway to get that to paint across all columns regardless? In large trees its really distracting and ugly. This screen shot is using Qt 4.3.2 and QSA 1.2.2 btw.

    Thanks,
    Chuck
    Attached Images Attached Images

  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: QTreeView -- Alternating Row Colors Oddity

    Are you sure each level of the model has the same number of columns? If you use QStandardItemModel it is important to call setColumnCount() with the same value for each level. For a custom model your columnCount() should return the same value for each index.

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

    chuckshaw (4th October 2007)

  4. #3
    Join Date
    Apr 2007
    Location
    United States
    Posts
    17
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTreeView -- Alternating Row Colors Oddity

    That was it. I reimplemented columnCount() in my custom model to return the same column count for all indexes like you suggested and it now correctly paints across the treeview.

    Thanks,
    Chuck

Similar Threads

  1. Draw a rectangle alternating two colors with qPainter
    By SkripT in forum Qt Programming
    Replies: 12
    Last Post: 24th January 2006, 23:12

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.