当前位置:网站首页>QT using layout manager is invalid or abnormal
QT using layout manager is invalid or abnormal
2022-06-13 04:54:00 【qq_ thirty-nine million two hundred and eighty thousand seven h】
1. Using the layout manager fails
Inherit and mainwindow Or... Again mainwindow The window of , Using layout manager will not work .
mainwindow Windows have their own layout management methods ,mainwindow There is a central part in the .
If you want to in mainwindow Use layout in , Sure new One widget parts , Then use the layout manager on the part ; Finally, set this component as the central component .
2. After using the layout manager , Cannot set the size of the part in it (setGeometry invalid ).
After using the layout manager , The size of the part position will be controlled by the layout manager . If you want to specify the size of the part , have access to setFixedsize function .
void QWidget::setFixedSize(const QSize &s)
Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking.
This will override the default size constraints set by QLayout
/*
Set the maximum size of the part , Minimum dimensions are s, Used to prevent stretching and expansion .
This operation will override the default limit of the layout manager .
*/3. Setting the layout management location size property is invalid (layout setGeometry)
The location attribute of the layout manager is inherited from the size of the parent part ( in the light of :QBoxLayout/QGridLayout).
QBoxLayout/QGridLayout website :
takes the space it gets (from its parent layout or from the parentWidget())
/* The size of the part comes from the parent part , Or father layout */Since the size of the layout manager is determined by the size of the parent part space , Then we can start with new One part , Then set the position and size of the part , Finally, add a layout manager to the part .
4. After adding various parts to the layout manager , For example, horizontal layout manager , Abnormal size and position of parts .
Layout manager contains “margin” The edge of .
qt website :
void QLayout::setContentsMargins(int left, int top, int right, int bottom)
Sets the left, top, right, and bottom margins to use around the layout.
By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
This function was introduced in Qt 4.3
/*
Set the top, bottom, left and right margins ,qt The default is 11px
*/You can use the following functions , Change the margins .
setMargin() function ( The official advice is not to use , Exists for compatibility with older versions )
setContensMargin()
边栏推荐
- Third party comment plugin
- Mysql database installation
- Tita绩效宝:远程一对一面谈的问题
- 2021tami/ image processing: exploiting deep generative priority for versatile image restoration and manipulation
- Go scheduled task cron package usage
- 约瑟夫问题
- Implementation of homepage header function in PHP development blog system
- Blockly learning ----1 Work area, block, toolbox
- How to use redis
- promise处理js多线程全部获得结果后同一处理结果
猜你喜欢

Advanced C - Section 2 - pointers

What is the difference between ROM, ram and flash? SRAM、DRAM、PROM、EPROM、EEPROM

Explain the differences and usage scenarios between created and mounted
![[try to hack] upload labs (temporarily write to 12)](/img/df/dbb78121f7428e25ffb73cfc43ce1b.png)
[try to hack] upload labs (temporarily write to 12)

【JS解决】leedcode 200. 岛屿数量

CreateAnonymousThreadX给匿名线程传递参数

C盘无损移动文件

josephus problem

Must know must know -c language keywords

Draw a hammer
随机推荐
Blockly learning ----1 Work area, block, toolbox
Go scheduled task cron package usage
Several methods of identifying equivalent circuit of circuit drawing
Tita: Xinrui group uses one-to-one talk to promote the success of performance change
如何优雅的处理async/await错误信息
Analysis on the usage, response and global delivery of provide/inject
Implementation of homepage header function in PHP development blog system
Use go to add massive data to MySQL
PowerDesigner easy to use
Reductive elimination
Hidden implementation and decoupling, knowing Pimpl mode
Colab使用教程(超级详细版)及Colab Pro/Pro+评测
E - Lucky Numbers
Normal distribution (Gaussian distribution)
[leetcode]- sliding window
Leetcode game 297 (20220612)
Brick story
Must know must know -c language keywords
Conception d'un système basé sur MVC avec javaswing JDBC
General communication protocol for industrial Internet