Reputation: 2520
I would like the horizontal scroll bar to appear whenever there is text eliding. Such that the user won't have to resize the whole GUI. How would I do this?
This is what I have coded:
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
ui->tableWidget->resizeColumnsToContents();
I also tried enabling scrollbar to appear always, but scrolling to the very right doesn't do anything.
If I set textElideMode
to ElideNone
, the text from the 2nd column is partially hidden and no scrollbar appears.
Upvotes: 1
Views: 7939
Reputation: 1229
QHeaderView::Stretch
will stretch the column width to the available space. Use QHeaderView::ResizeToContents
to make the column wide enough to display the content, resulting in a horizontal scroll bar if necessary.
This will have a couple of side effects of which I'm not sure you want them.
Upvotes: 2