Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Behave differently in qt 5.9.4.



  •  #include <QApplication>
     #include <QTableView>
     #include <QStandardItem>
     #include <QStandardItemModel>
    int main(int argc, char *argv[])
     {
     QApplication a(argc, argv);
     QTableView view;
     QStandardItemModel model;
     model.setHorizontalHeaderItem(0, new QStandardItem(QObject::tr("Column 1")));
     model.setHorizontalHeaderItem(1, new QStandardItem(QObject::tr("Column 2")));
     model.setItem(0, 0, new QStandardItem("a"));
     model.setItem(0, 1, new QStandardItem("b"));
     view.setModel(&model);
     view.setSortingEnabled(true);
     view.show();
    return a.exec();
     }
    

    Run above code, then change colum width. Column width will be reset to default when I click HorizontalHeader to perform a sorting.
    Such behavior is not seen in qt 5.9.3 or qt 5.10.1. platform is linux
    Does anyone know the trick?

    I have reported a bug, but no response now.


  • Moderators

    @Mr-Pang To be honest the 5.9.4 sounds like a bug that was fixed in 5.10. If you change the width on a column it should not resize for you when you click the column to sort.


  • Lifetime Qt Champion

    The report is: https://bugreports.qt.io/browse/QTBUG-67131

    @Mr-Pang: It looks like your problem is https://bugreports.qt.io/browse/QTBUG-65478 which should be fixed in Qt 5.9.5.


Log in to reply