QTableWidget: how to stretch columns?
Hi, I'd like to know how to stretch a QTableWidget's columns from the designer? thanks.
QListWidget doesn't have columns afaik (TextMode). Are you talking about IconMode ? What exactly you want to resize ?
[quote author="zeljko" date="1398791061"]QListWidget doesn't have columns afaik (TextMode). Are you talking about IconMode ? What exactly you want to resize ?[/quote]
Sorry, I was wrong about the QListWidget: it's in reality about QTableWidget.
so how to do that?
Slots: QTableView::resizeColumnToContents(int: column); and
is what you are searching for. Don't know if it's possible directly from designer (but since they're slots it should be), but in code it is.
I found that you can change all columns by going to tableWidget : QTableWidget -> Header -> horizontalHeaderDefaultSectionSize. However, I did not find a QDesigner way of changing a single column width.
There is way to stretch the column in QTableWidget in Designer also.
- Open the Qt designer.
- Select QTableWidget item which you already placed on your form.
- See the property box at right hand side.
- Scroll down to QTable Widget
- Under Header section you will find options to resize it as,
- horizontalHeaderDefaultSectionSize increase as you want & try it out
- horizontalHeaderStretchLastSection make it true so your empty space after last column will be filled by stretched last column.
Do your own tryouts on that there are plenty of option to do.