Controls insist on being too large, and won't resize, in QtDesigner

[亡魂溺海] 提交于 2019-11-28 21:35:40
Fivos Vilanakis

Don't blame yourself, I think Qt's Layout logic is a bit confusing when you start to deal with. If I understood well what you are saying, the contents of the form are not "connected", i.e. not resizing and not restricted by the form size, right? I think you have missed to set a "centralWidget layout". Try the following:

  1. Open your form by double clicking it in QtCreator (I don't use the QtDesigner frequently but I think the editor layout is almost the same on both tools).

  2. Go to the top-right window (the one having 2 columns "Object-Class") and Right-Click with your mouse at the root object (e.g. MainWindow).

  3. A context menu will appear. Click on "Lay out" (last menu item) and select "Layout Vertically" or "Layout Horizontally"

These actions will create a layout on the centralWidget object. If you select the "centralWidget" in the "Object-Class" window you can then view & change the layout properties in the (bottom-right) Property-Value window; they are the last properties in list.

More important, after you add a layout in your centralWidget, the contents of your form should be resizing along & limited by your form's size.

I hope this helps.

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