How can size of QMainWindow's central widget be managed?
Hi,
I have a main window with a central widget which can grow horizontally when needed but should not grow vertically (just like horizontal slider) along-with 4 dock widgets. Problem is that when the main window's size is increased, central widget's vertical size is also increased, which should not be happening. I have tried with no success.
Can you please show me the way?
Regards,
Re: How can size of QMainWindow's central widget be managed?
Try setting a maximum height to the widget.
Re: How can size of QMainWindow's central widget be managed?
Quote:
Originally Posted by
high_flyer
Try setting a maximum height to the widget.
I tried with
Code:
setFixedHeight(sizeHint().height());
Now the widget's vertical size remains constant but the area which is supposed to be occupied by central widget is still not restricted resulting in empty area below the widget.
Re: How can size of QMainWindow's central widget be managed?
Why should it be restricted? You said you didn't want the central widget size to change and it doesn't change. You don't want the main window size to change as well? If so, then either set its maximum height or set a layout constraint on it.
Re: How can size of QMainWindow's central widget be managed?
Quote:
Originally Posted by
wysota
Why should it be restricted? You said you didn't want the central widget size to change and it doesn't change. You don't want the main window size to change as well? If so, then either set its maximum height or set a layout constraint on it.
Yes, now height of central widget does not change but what's the point of having empty space below it when that space can be effectively used by other dock widgets?
Please look at the following screen-shots for a better idea.
Optimum size:
http://img716.imageshack.us/img716/7153/ss1.th.png
After increasing window's size:
http://img697.imageshack.us/img697/6558/ss2uw.th.png
Re: How can size of QMainWindow's central widget be managed?
I don't know if it is the best way to do it, but I would use a QWidget with two QWidgets on it. Set the central widget to the parent, and give the parent a horizontal layout. Put the things you want to stay constant on the top widget and give that widget a fixed size. The bottom widget, with your list of songs will expand then as necessary.
Re: How can size of QMainWindow's central widget be managed?
Quote:
Originally Posted by
JPNaude
I don't know if it is the best way to do it, but I would use a QWidget with two QWidgets on it. Set the central widget to the parent, and give the parent a horizontal layout. Put the things you want to stay constant on the top widget and give that widget a fixed size. The bottom widget, with your list of songs will expand then as necessary.
This is good only for simple case not when you have a number of dock widgets giving you the complete control over the placement of each dock.
http://img641.imageshack.us/img641/8927/ss3.th.png
http://img63.imageshack.us/img63/6603/ss4z.th.png
Re: How can size of QMainWindow's central widget be managed?
Hi, I'm facing the exact same problem. Have you already found a solution for it? If so, would you please share it?
Thanx in advance
Jonny
Re: How can size of QMainWindow's central widget be managed?
What problem? This thread discusses correct operation of the Qt layout system
1 Attachment(s)
Having the same issue with resizing
I'm facing the same issue and I haven't found anyone who appears to have solved it, at least in a way that Google can find. :(
Like the OP, I have a central widget and a number of dockwidgets. In my case the dockwidgets are to the right of the central widget.
When the main window is resized, I want the dock widgets to grow to fill the horizontal space and the central widget to remain fixed. Yet, of course, the exact opposite happens.
And the central widget is immune to any attempts at setting a size policy.
The behavior I describe seems like it should be the standard behavior, yet it's apparently very difficult to achieve.
Is there any simple way to have dockwidgets expand to fill the space while the central widget remains fixed?
Attachment 10201