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

Set font on QTreeWidget will cause the first column to ridiculously expand its width.

    XMLWordPrintable

Details

    • 024a52d0d12aaceffd67d0a1423408fb1f377d11

    Description

      Please see the attached test program from [^tablewidgettest_v1.zip] archive.

      int main( int argc, char **argv )
      {
          QApplication app( argc, argv );
      
          QTreeWidget w;
          QStringList headerLabels;
          headerLabels << "Column 1" << "Column 2" << "Column 3";
      
          w.setFont(QFont ("Courier", 9));
      
          w.setHeaderLabels(headerLabels);
      
          QTreeWidgetItem* item = new QTreeWidgetItem(&w);
          item->setText(0, "test1");
          item->setText(1, "test2");
          item->setText(2, "test3");
          w.addTopLevelItem(item);
          w.show();
      
          return app.exec();
      }
      
      • Calling setColumnCount(3) (option -c) before setFont() fixes the issue
      • Calling w.resizeColumnToContents() (option -j) also fixes the issue

      Attachments

        1. qtbug39010_diag.diff
          9 kB
        2. qtbug39010_set_font_after_header.log
          8 kB
        3. qtbug39010.log
          7 kB
        4. qtbug39010.zip
          1 kB
        5. treewidgettest_v1_screen.png
          treewidgettest_v1_screen.png
          10 kB
        6. treewidgettest_v1.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tmartsum Thorbjørn Lund Martsum
            leonlee Leonard Lee
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes