active resizing of widgets inside mainwindow

2019-05-02 01:19发布

I have a few widgets in a main window. enter image description here i want the user to be able to resize the widgets inside the window as they please, just like how one would resize the main window. Do I have to make a layout container to enable this? or ....layout? Buh the layout contains are static once the window is rendered. In the picture the three widgets should be enable with resizing such that the user can drag their sides/corners to expand or minimize the widget size.

1条回答
2楼-- · 2019-05-02 01:51

One thing you could do is to use some QSplitter's though it isn't directly as nuanced as you pointed out. Have a look at the image (you can drag the handles):

enter image description here

Another thing is to place the widgets using absolute coordinates and then detect when the cursor is clicked and dragged on the "edge". Then you calculate how much it should be resized and actually resize the widget according to its position.

You could also have a look at the QMdiArea and then add your widgets using addSubWindow() where you also set the window flags.

查看更多
登录 后发表回答