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

QTableView Column setSectionResizeMode and Font



  • i have a table View, and column count 3

    setColumnWidth 0 -> 30
    setColumnWidth 1 -> 150
    setColumnWidth 2-> 150

    horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeMode::Stretch);

    Depending on the font, the width of the column may change, but what should be done to not change it?



  • @Qt-Jo-Ha
    This should produce 3 columns: width 30, width 150, width whatever to stretch to fit.

    If you are saying some of the columns grow wider to fit their content, perhaps according to font, and you do not want that, then I think look at using horizontalHeader()->setSectionResizeMode(column, QHeaderView::Fixed); for each column?


Log in to reply