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

QT 5.5 and QTableView column size adjustment..



  • Hello All!
    How can I make the columns of a table make be "auto ajust" with content... I have try this and doesn't works:

    ui->tableLooger->resizeRowsToContents();
    ui->tableLooger->resizeColumnsToContents();

    I have done some code on older versions and this works for me, but now in 5.5 appers to be different. I found some tips that say's to use that: "ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);" but the "setResizeMode" in the new API doesn't exists.

    Thanks for the help!


  • Lifetime Qt Champion

    Hi,

    The new API is setSectionResizeMode



  • Thank you very much!!!!

    ui->tableLooger->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

    Now this uses all space from QTableView.


  • Lifetime Qt Champion

    You're welcome !

    Since you have it working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

    Also, consider up-voting answer(s) that helped you so the other users may find them more easily.


Log in to reply