Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2442

QTreeView does not account for the height of the columns outside of the viewport

    XMLWordPrintable

Details

    Description

      QTreeView does not account for the height of the columns
      that are outside of the viewport when calculating the height of an item.

      This leads to a corrupted display as the example in attachment shows.

      Both items should have height of at least 128 pixels, which is the size
      of the pixmap inserted in the first column. But since the first column
      isn't actually in the viewport then the height is incorrectly computed
      as the height of the text present in the visible columns.

      If the first column is in the viewport when the widget shows up then the items
      have the correct height.

      If the pixmap is inserted in a column that is far on the right and
      the view isn't scrolled then the problem doesn't show up even if
      the pixmap is outside of the view. This suggests that the bug
      affects only the left side of an item.

      A common example is when items are added at runtime and the user has scrolled the view manually.

      #include <QtGui>

      int main(int argc,char ** argv)
      {
      QApplication app(argc,argv);

      QTreeWidget * tw = new QTreeWidget( 0 );
      tw->setAllColumnsShowFocus( true );
      tw->setExpandsOnDoubleClick( true );

      QStringList headerLabels;
      headerLabels.append( "COLUMN 1" );
      headerLabels.append( "COLUMN 2" );
      headerLabels.append( "COLUMN 3" );
      headerLabels.append( "COLUMN 4" );
      headerLabels.append( "COLUMN 5" );
      headerLabels.append( "COLUMN 6" );
      headerLabels.append( "COLUMN 7" );
      headerLabels.append( "COLUMN 8" );
      tw->setHeaderLabels( headerLabels );

      QPixmap pix( 128,128 );
      pix.fill( QColor( 255,0,0 ) );

      QTreeWidgetItem * par = new QTreeWidgetItem( tw );
      par->setIcon( 0, pix );
      par->setText( 0, "PARENT COLUMN 1" );
      par->setText( 1, "PARENT COLUMN 2" );
      par->setText( 2, "PARENT COLUMN 3" );
      par->setText( 3, "PARENT COLUMN 4" );
      par->setText( 4, "PARENT COLUMN 5" );
      par->setText( 5, "PARENT COLUMN 6" );
      par->setText( 6, "PARENT COLUMN 7" );
      par->setText( 7, "PARENT COLUMN 8" );

      QTreeWidgetItem * item = new QTreeWidgetItem( par );
      item->setIcon( 0, pix );
      item->setText( 0, "CHILD COLUMN 1" );
      item->setText( 1, "CHILD COLUMN 2" );

      //mt->runAllTests();

      tw->setIconSize( QSize( 128, 128 ) );
      tw->show();

      tw->horizontalScrollBar()->setValue( 500 );
      par->setExpanded( true );

      return app.exec();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            monsen Marius Bugge Monsen
            dettman Dean Dettman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes