当前位置:网站首页>QT qsplitter splitter
QT qsplitter splitter
2022-07-02 22:54:00 【Mr.codeee】
1. brief introduction
QSplitter The splitter allows users to control the size of subassemblies by dragging the boundaries between them .
A single splitter can control any number of widgets .QSplitter The typical use of is to create several widgets , And use insertWidget() or addWidget() Add them .
2. Common methods
void addWidget(QWidget *widget) | add to widget |
int count() const | Returns the number of widgets contained in the splitter layout . |
void setOrientation(Qt::Orientation) | Set the direction , level , vertical , Default horizontal |
void setStretchFactor(int index, int stretch) | Set the expansion coefficient |
void insertWidget(int index, QWidget *widget) | Insert widget |
By default ,QSplitter Will dynamically adjust the size of its child elements . If you wish QSplitter Adjust the size of child elements only at the end of the resizing operation , So called setOpaqueResize(false).
void setOpaqueResize(bool opaque = true)
Set the respective sizes of the subassemblies to the values given in the list .
If splitter It's horizontal , Then these values will set the width of each widget in pixels , From left to right .
If splitter It's vertical , Then set the height of each widget from top to bottom
void setSizes(const QList<int> &list)
3. Example
3.1 Expansion coefficient
add to 3 individual QPlainTextEdit, Added in the default horizontal way , And set the expansion coefficient , I personally understand , Expansion coefficient , like , ratio . The scale of the above figure is 2:1:1.
Source code :
QSplitter *s1 = new QSplitter(this);
ui->verticalLayout->addWidget(s1);
// add to 3 individual widget
QPlainTextEdit *t1 = new QPlainTextEdit(s1);
t1->setPlaceholderText("t1");
QPlainTextEdit *t2 = new QPlainTextEdit(s1);
t2->setPlaceholderText("t2");
QPlainTextEdit *t3 = new QPlainTextEdit(s1);
t3->setPlaceholderText("t3");
s1->addWidget(t1);
s1->addWidget(t2);
s1->addWidget(t3);
s1->setStretchFactor(0,2);
s1->setStretchFactor(1,1);
s1->setStretchFactor(2,1);
3.2 setOpaqueResize(false) effect
The default is true, The effect is as follows
3.3QSplitter Nesting with each other
Source code :
QSplitter *mainSplitter = new QSplitter(this);
ui->verticalLayout->addWidget(mainSplitter);
QSplitter *rightSplitter = new QSplitter(mainSplitter);
rightSplitter->setOrientation(Qt::Vertical); // Set the vertical direction
// add to 3 individual widget
QPlainTextEdit *t1 = new QPlainTextEdit(mainSplitter);
t1->setPlaceholderText("t1");
QPlainTextEdit *t2 = new QPlainTextEdit(rightSplitter);
t2->setPlaceholderText("t2");
QPlainTextEdit *t3 = new QPlainTextEdit(rightSplitter);
t3->setPlaceholderText("t3");
rightSplitter->addWidget(t2);
rightSplitter->addWidget(t3);
mainSplitter->addWidget(t1);
mainSplitter->addWidget(rightSplitter);
边栏推荐
- Simpleitk use - 3 Common operations
- Golang面试整理 三 简历如何书写
- 'when to use const char * and when to use const char []' - when to use const char * and when to use const char []
- Task and privilege level protection
- go 4种单例模式
- Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
- LeetCode 968. 监控二叉树
- UE4 UI adaptive screen
- UE4 game architecture learning notes
- Notes on key vocabulary of the original English book biography of jobs (IX) [chapter seven]
猜你喜欢
Wait to solve the zombie process
Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
`Usage of ${}`
牛客网:龙与地下城游戏
Hanging mirror security won four global infosec awards on rsac2022
Uniapp wechat login returns user name and Avatar
加油站[问题分析->问题转换->贪心]
[error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
性能优化----严苛模式
随机推荐
[LeetCode] 反转字符串【344】
[error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
Simpleitk use - 3 Common operations
PHP optimizes SQL queries in foreach
Go condition variable
wait解决僵尸进程
[NPUCTF2020]ezlogin xPATH注入
Notes on key vocabulary of the original English book biography of jobs (IX) [chapter seven]
`${}`的用法
从2022年Q1财报看携程的韧性和远景
Gas station [problem analysis - > problem conversion - > greed]
Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
Hanging mirror security won four global infosec awards on rsac2022
Storage unit conversion
[chestnut sugar GIS] ArcMap - why should the tick of classic capture be removed when using custom capture?
全面解析分享购商业模式逻辑?分享购是如何赋能企业
[LeetCode] 回文数【9】
Based on asp Net (used mobile phone sales management system) +asp Net+c # language +vs2010+ database can be used for course design and post design learning
服务器响应状态码
LeetCode 968. 监控二叉树