Important: Please read the 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"));
    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:

    @Mr-Pang: It looks like your problem is which should be fixed in Qt 5.9.5.

Log in to reply