Minimum height of QTableView
-
I have a table view in a dockable window. The geometry is shown in Qt Designer with a width of 600 and height of 190 and I cannot work out how to change it ( want to reduce the minimum height to about (say) 60 px).
Am I missing something very obvious? I tried changing the minimum height to 60 px but that didn't help.
Thanks
David -
tableView = new QTableView(dockWidgetContents); tableView->setObjectName("tableView"); tableView->setMinimumSize(QSize(600, 175)); tableView->setSelectionMode(QAbstractItemView::ExtendedSelection); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setSortingEnabled(true); tableView->verticalHeader()->setVisible(false);
The ui file said the same for minimum size.
I edited the ui file to change the minimum height to 60, and rebuilt. the header file now says:
tableView->setMinimumSize(QSize(600, 60));
but I still cannot resize the table view that small!!!
If I open the ui file in Designer the geometry still reports 600*192
David
-
@Perdrix ui_something file is dynamically generated from the ui xml file created in designer. Nothing will change if you change anything inside ui_something file. But you can see what is wrong there.
if tableView->setMinimumSize(QSize(600, 175)); is defined in ui_something file, that means its minimum height is 175, not 60 as you expect.
In Designer, you might not set minimum size properly. Open the xml ui file in an editor and check the minimum size of this tableView. -
@Perdrix
Hi David,
I think the table view'sQWidget::sizePolicy()
can help to achieve the required behavior.
You can set it programmatically or in designer.
Cheers
Axel -
@Axel-Spoerl Thanks, Axel. Currently it is set Expanding,Expanding
What should I set to allow it to be resizeable to the minimum size I set (currently set to 600x60).
I tried setting a size policy of (Expanding, MinimumExpanding) but that didn't change the geometry at all, I also couldn't resize the widget smaller in Designer.
D.
-