Results 1 to 10 of 10

Thread: QTreeWidget - BUG

  1. #1
    Join Date
    Jun 2008
    Posts
    25
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default QTreeWidget - BUG

    For my QTreeWidget [say 4 rows and 10 columns]the first column have tree items with icons. Sorting is also enabled for the QTreeWidget

    If i just drag the horizontal scroll bar to the right in such a way that the first is not visible. Then try to sort based on a visible column.

    Now all the rows height got reduced to a smaller size. This seems to be a QT Bug.

    I have attached a UI file for verifying this bug

    Is there any workaround for this issue ?
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: QTreeWidget - BUG

    Can't reproduce your problem here. What environment do you use?

  3. #3
    Join Date
    Jun 2008
    Posts
    25
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default Re: QTreeWidget - BUG

    Quote Originally Posted by Lykurg View Post
    Can't reproduce your problem here. What environment do you use?
    The issue is observed even in QT 4.7.0 in windows

    I just attached few snap shots of the Bug.

    the issue can be reproduced just by using the QT Designer
    Attached Images Attached Images

  4. #4
    Join Date
    Jun 2008
    Posts
    25
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default Re: QTreeWidget - BUG

    Is there still any issues in reproducing the issue.

    QT experts, Is there any work around ?

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

    Default Re: QTreeWidget - BUG

    Could you prepare a minimal compilable example reproducing the problem?
    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.


  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QTreeWidget - BUG

    In your screen shot you have icons (32x32 in the UI file) on a few rows other than the first. In your provided UI file you have the uniformRowHeights option turned on. From the doc for QTreeView::uniformRowHeights():
    This property should only be set to true if it is guaranteed that all items in the view has the same height. This enables the view to do some optimizations.
    The height is obtained from the first item in the view. It is updated when the data changes on that item.
    Your application fails on the first point because the icons are clearly taller than the natural/default height for the rows without an icon. The second point means that the first row is used to fix the height, and truncates the icons on subsequent rows, because you have told it that it can make this assumption. When you sort you change the first row and potentially the uniform row height.

    Start by turning off that option (or have your model return a better size hint)
    Last edited by ChrisW67; 7th October 2010 at 02:41. Reason: Explained why the height might change with sort

  7. #7
    Join Date
    Jun 2008
    Posts
    25
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default Re: QTreeWidget - BUG

    Quote Originally Posted by ChrisW67 View Post
    In your screen shot you have icons (32x32 in the UI file) on a few rows other than the first. In your provided UI file you have the uniformRowHeights option turned on. From the doc for QTreeView::uniformRowHeights():

    Your application fails on the first point because the icons are clearly taller than the natural/default height for the rows without an icon. The second point means that the first row is used to fix the height, and truncates the icons on subsequent rows, because you have told it that it can make this assumption. When you sort you change the first row and potentially the uniform row height.

    Start by turning off that option (or have your model return a better size hint)
    Thanks for the response.

    As per your suggestions i just turned off QTreeView::uniformRowHeights().
    Also put the same icons for all the Rows.

    Still the issue is there !!

    If the column with the icons are visible there is no change in the row height and working perfect.

    But when the column with the icons are not visible [when we drag the horizontal scroll bar], the row heights are getting reduced.

    The modified UI file is also attached here
    Attached Files Attached Files

  8. #8
    Join Date
    Jun 2008
    Posts
    25
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default Re: QTreeWidget - BUG

    Quote Originally Posted by George Neil View Post
    Thanks for the response.

    As per your suggestions i just turned off QTreeView::uniformRowHeights().
    Also put the same icons for all the Rows.

    Still the issue is there !!

    If the column with the icons are visible there is no change in the row height and working perfect.

    But when the column with the icons are not visible [when we drag the horizontal scroll bar], the row heights are getting reduced.

    The modified UI file is also attached here
    Experts, Is there any fix to this issue ?

    Is there still any difficulty in reproducing the issue ?

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,375
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QTreeWidget - BUG

    You still didn't provide a minimal compilable example reproducing the problem.
    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.


  10. #10
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QTreeWidget - BUG

    This shows the behaviour the OP describes (on Linux, Qt 4.6.3):
    Qt Code:
    1. #include <QtGui>
    2. int main(int argc, char *argv[])
    3. {
    4. QApplication app(argc, argv);
    5.  
    6. // Create a 32x32 icon
    7. QPixmap pixmap(32,32);
    8. QPen pen(Qt::green, 1, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
    9. QPainter painter(&pixmap);
    10. painter.fillRect(QRectF(0,0,32,32), Qt::white);
    11. painter.setPen(pen);
    12. painter.drawRect(QRect(1,1, 30, 30));
    13.  
    14.  
    15. tree.setColumnCount(10);
    16. tree.setSortingEnabled(true);
    17.  
    18. for (int row=0; row<10; ++row)
    19. {
    20. for (int col=0; col<10; ++col)
    21. list << QString("R%1 C%2").arg(row).arg(col);
    22. QTreeWidgetItem *item = new QTreeWidgetItem(&tree, list);
    23. item->setData(0, Qt::DecorationRole, pixmap);
    24. tree.addTopLevelItem(item);
    25. }
    26.  
    27. tree.show();
    28.  
    29. return app.exec();
    30. }
    To copy to clipboard, switch view to plain text mode 
    If you sort with any part of column zero visible then it works as expected. If column zero is not visible then the sort resizes the row height and truncates the icons.

  11. The following user says thank you to ChrisW67 for this useful post:

    George Neil (11th October 2010)

Similar Threads

  1. Qtreewidget
    By newermind in forum Qt Programming
    Replies: 1
    Last Post: 4th May 2009, 12:09
  2. Replies: 2
    Last Post: 17th March 2008, 13:53
  3. Replies: 1
    Last Post: 19th October 2007, 02:29
  4. QTreeWidget
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2007, 16:03
  5. QTreeWidget
    By merry in forum Qt Programming
    Replies: 4
    Last Post: 28th May 2007, 13:51

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.