PDA

View Full Version : Resizing QMainWindow according to QTableWidget size



agl5
5th January 2012, 23:17
Hi, i have a QMainWindow's central widget with QHBoxLayout, which contains 2 frames. Left frame is a QVBoxLayout with some buttons etc. Right frame is also a QVBoxLayout, but it contains a QTableWidget, that can represent tables with different numbers of columns and rows. I am trying to make QMainWindow to resize according to left + right frames' width and height.

I subclassed QTableWidget, setted its sizepolicies to (Minimum,Minimum), reimplemented its sizehint method. I also setted left and right frames' sizepolicies to (maximum, preferred). I use resize() to mainwindow with slot method where i calculate both frames' widths. So it works fine, but if QTableWidget becomes too large to fit the screen, i can't shrink the mainwindow, because of QTableWidget setted sizepolicies (Minimum,Minimum). With other sizepolicies it doesn't work at all - right frame doesn't grow and mainwindow has a size of left frame.

How can i solve my problem? Or may be there is another more appropriate solution? Thanks for help.

agl5
10th January 2012, 14:41
Well, solved my problem by limiting x and y sizes in QTableWidget sizeHint() , but still this sizepolicies aren't clear for me...