Search code examples
c++qtqtreeview

How to span the Columns of a QTreeView in C++/Qt?


I Want to have some long text in one of my columns of the qtreeview (not the first column). This text has to be shown completely but it does not expand. There is a method called SetFirstColumnSpanned. But it only works for the first column. Any ideas of how to span the other columns?


Solution

  • Try to use QHeaderView::setResizeMode ( int logicalIndex, ResizeMode mode )

    For example:

    tableView->horizontalHeader()->setResizeMode(column_number, QHeaderView::ResizeToContents);