当前位置:网站首页>QT learning 24 layout manager (III)
QT learning 24 layout manager (III)
2022-07-03 13:58:00 【A little black sauce】
Qt Study 24 Layout manager ( 3、 ... and )
reflection
How to design the following graphical user interface ?

Solution
- Absolute positioning Coordinates and size of the assembly
- nesting QBoxLayout
- establish 3*2 Of QGridLayout

The above three methods are more or less problematic , Absolute positioning Coordinates need to be calculated , nesting QBoxyLayout Need to use 4 A layout manager , and 3*2 Of QGridLayout When the window size changes , It will cause the problem of fixed proportion coefficient .
QFormLayout Layout manager
With Forms (Form) Manage interface components in a way
Form layout The tags and components in are Corresponding to each other The relationship between
QFormLayout Usage Summary of
- void addRow(QWidget *label, QWidget *field)
- void addRow(QWidget *label, QLayout *field)
- void addRow(const QString& labelText, QWidget *field)
- void addRow(const QString& labelText, QLayout *field)
Form layout Support nested , Other layout managers can be managed as sub layouts
Programming experiment
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
};
#endif // WIDGET_H
#include "Widget.h"
#include <QLineEdit>
#include <QFormLayout>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
QLineEdit *nameEdit = new QLineEdit();
QLineEdit *mailEdit = new QLineEdit();
QLineEdit *addrEdit = new QLineEdit();
QFormLayout *layout = new QFormLayout();
layout->addRow("Name:", nameEdit);
layout->addRow("Email:", mailEdit);
layout->addRow("Address:", addrEdit);
// layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
layout->setRowWrapPolicy(QFormLayout::WrapLongRows); // Adaptive labels and edit boxes
layout->setSpacing(10);
setLayout(layout);
setWindowTitle("FTP");
}
Widget::~Widget()
{
}
#include "Widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
QFormLayout Style function of
- void setRowWrapPolicy(RowWrapPolicy policy)
- void setLabelAlignment(Qt::Alignment alignment)
Nesting of layout managers

Summary
- QFormLayout With Forms Manage interface components in a way
- QFormLayout Of style Set up concise clear
- QFormLayout Support the nesting of layout managers
- QFormLayout Embedded products The most commonly used layout
边栏推荐
- 解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
- Go language web development series 28: solve cross domain access of CORS with gin contrib / CORS
- The solution of Chinese font garbled code in keil5
- jvm-类加载
- Halcon combined with C # to detect surface defects -- Halcon routine autobahn
- NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
- [bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
- Universal dividend source code, supports the dividend of any B on the BSC
- 交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
- JS continues to explore...
猜你喜欢

Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware

The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can

Spring cup eight school league

从零开始的基于百度大脑EasyData的多人协同数据标注
[email protected])|制备路线"/>叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线

The solution of Chinese font garbled code in keil5
[email "/>Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email

RocksDB LRUCache

【吉林大学】考研初试复试资料分享

Mobile phones and computers can be used, whole people, spoof code connections, "won't you Baidu for a while" teach you to use Baidu
随机推荐
Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email
Multi person collaborative data annotation based on Baidu brain easydata from scratch
SQL Injection (POST/Search)
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
Mastering the cypress command line options is the basis for truly mastering cypress
Another industry has been broken by Chinese chips. No wonder the leading analog chip companies in the United States have cut prices and sold off
MySQL data processing value addition, deletion and modification
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
Screenshot of the operation steps of upload labs level 4-level 9
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
Similarities and differences of sessionstorage, localstorage and cookies
Leetcode-1175.Prime Arrangements
GoLand 2021.2 configure go (go1.17.6)
全面发展数字经济主航道 和数集团积极推动UTONMOS数藏市场
How to use lxml to judge whether the website announcement is updated
jvm-类加载
Implementation of Muduo asynchronous logging
C language standard IO function sorting
3D视觉——2.人体姿态估计(Pose Estimation)入门——OpenPose含安装、编译、使用(单帧、实时视频)
Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry