active resizing of widgets inside mainwindow

不羁的心 提交于 2019-12-07 04:02:44

问题


I have a few widgets in a main window.

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:


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):

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.



来源:https://stackoverflow.com/questions/8233263/active-resizing-of-widgets-inside-mainwindow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!