当前位置:网站首页>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()
边栏推荐
- [try to hack] upload labs (temporarily write to 12)
- Tita performance treasure: remote one-on-one discussion
- Embedded hardware - read schematic
- Recommended temporary online image compression tool
- 【JS解决】leedcode 200. 岛屿数量
- 使用Service Worker优选请求资源 - 持续更新
- How to implement a custom jdbc driver in only four steps?
- JS, how to add grid style
- Go/golang connection to database
- Explain the differences and usage scenarios between created and mounted
猜你喜欢
CMB written test graphical reasoning
Logical point
Several methods of identifying equivalent circuit of circuit drawing
Keil uses j-link to burn the code, and an error occurs: Flash download failed - one of the "Cortex-M3" solutions
RuoYi-Cloud启动教程(手把手图文)
2021TPAMI/图像处理:Exploiting Deep Generative Prior for Versatile Image Restoration and Manipulation
Section 2 - branch and loop statements
【JS解决】leedcode 200. 岛屿数量
Embedded hardware - read schematic
[JS solution] leedcode 117 Populate the next right node pointer II for each node
随机推荐
Infinite cycle scrolling code Alibaba international station store decoration code base map scrolling black translucent display effect custom content decoration code full screen display
RuoYi-Cloud启动教程(手把手图文)
Force deduction 121 questions
Tita绩效宝:远程一对一面谈的问题
Crawler scrapy framework learning 2
[JS solution] leedcode 117 Populate the next right node pointer II for each node
Leetcode game 297 (20220612)
Several methods of identifying equivalent circuit of circuit drawing
Hidden implementation and decoupling, knowing Pimpl mode
Avantages de win8.1 et win10
如何只用4步,实现一个自定义JDBC驱动?
String()和toString()方法得区别
Mysql database installation
2022 oxidation process operation certificate examination question bank and simulation examination
2022道路运输企业安全生产管理人员操作证考试题库及答案
Collection of some compatibility issues
Autumn wind, dust, youth
PostgreSQL Guide: Insider exploration (Chapter 7 heap tuples and index only scanning) - Notes
Conception d'un système basé sur MVC avec javaswing JDBC
Go scheduled task cron package usage