c++windowsqtqtablewidgetminimum-size

How to set QTableWidget height under 70


I am using Qt5.3.0 with Qt Creator. I want to have a really small QTableWidget which the widget height can be 10. I will make sizePolicy to expanded so that it can be expanded to a larger number.

This is what I did:
1. Create a Qt application with MainWindow.
2. Drag a QTableWidget in MainWindow.
3. Apply a verticalLayout to Mainwindow.
4. Build and Run.

I will get the table but I cannot make it shorter than 70 by adjusting the window's size with the rightbottom corner triangle thing (resize triangle?).

I've also tried to subclass QTableWidget and return sizeHint but it doesn't help. What did I miss?


Solution

  • Set the minimum height of the QTableWidget to 10. By default it has some kind of an internal minimum height and it behaves like you described.

    tableWidget->setMinimumHeight(10);
    

    or just set it in QtCreator UI editor property.