简体   繁体   中英

Qt prevent controls moving when window resized

I have a Qt application which has a window based on a QWdiget . Inside my window I have two QVBoxLayout s and one QHBoxLayout with controls underneath the first two Vertical layouts. When my window is resized, the QVBoxLayout move apart and the QHBoxLayout underneath also moves away. I want to prevent this from happening, what is the best way to do this?

All these layouts are inside a QGridLayout .

If I understand your question correctly, you have a window's layout like this : 窗户布置

The layouts is going to resize depending on the size of the objects in them. To solve your problem, you should set the alignment of your layouts within the grid layout using setAlignment method.

by the way, if nothing works, you can always write your own layout manager .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM