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

Branch indicator not centered in QTreeView with custom icon size

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.3
    • Widgets: Itemviews
    • None
    • macOS

    Description

      QTreeView: When setting a custom iconSize the branch indicator is no longer centered vertically.

       

      #include <QtWidgets> 
      #include <QtGui> 
      #include <QPixmap>
      
      int main(int argc, char *argv[]) 
      { 
         QApplication a(argc, argv); 
      
         const QSize iconSize(32, 32);
         QPixmap icon(iconSize);
         icon.fill(Qt::red);
      
         // Build a model 
         QStandardItemModel model(5, 1); 
         for (int r=0; r<5; r++) { 
             QStandardItem* item = new QStandardItem("Parent"); 
             item->setIcon(icon);
             for (int i=0; i<3; i++) { 
                 QStandardItem* child = new QStandardItem("Child"); 
                 item->appendRow(child); 
             } 
             model.setItem(r, 0, item); 
         } 
      
         QMainWindow window; 
         QTreeView* tree = new QTreeView();
         tree->setIconSize(iconSize);
         tree->setModel(&model); 
         window.setCentralWidget(tree); 
         window.show(); 
         return a.exec(); 
      }
      
      

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            otronarp Otto Tronarp
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes