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

QTableView::stretchLastSection interferes with QTableView::resizeSection



  • Basically, I want the first column to always have a fixed width of 21 pixels but if I set QTableView::stretchLastSection property to true, it gets resized to 23 pixels or so. It looks like it worked before but now doesn't work with Qt 5.9.5 anymore

    This code works:

    table->horizontalHeader()->setStretchLastSection(false);
    table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed);
    table->horizontalHeader()->resizeSection(0, 21);
    

    This code doesn't:

    table->horizontalHeader()->setStretchLastSection(true);
    table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed);
    table->horizontalHeader()->resizeSection(0, 21);
    

    Does anyone have same issue?



  • It seems I have fixed this issue by setting minimumSectionSize equal to 21


Log in to reply