当前位置:网站首页>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
边栏推荐
- How to use lxml to judge whether the website announcement is updated
- Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
- GoLand 2021.1.1: configure the multi line display of the tab of the open file
- Selenium browser (1)
- Unity embeddedbrowser browser plug-in event communication
- Golang — 命令行工具cobra
- 3D vision - 2 Introduction to pose estimation - openpose includes installation, compilation and use (single frame, real-time video)
- Mobile phones and computers can be used, whole people, spoof code connections, "won't you Baidu for a while" teach you to use Baidu
- 挡不住了,国产芯片再度突进,部分环节已进到4nm
- 金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
猜你喜欢

UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料

HALCON联合C#检测表面缺陷——HALCON例程autobahn

交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳

FPGA测试方法以Mentor工具为例

Go language web development series 30: gin: grouping by version for routing

Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)

Golang - command line tool Cobra

Comprehensive case of MySQL data addition, deletion, modification and query

Using registered classes to realize specific type matching function template

掌握Cypress命令行选项,是真正掌握Cypress的基础
随机推荐
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
软件测试工作那么难找,只有外包offer,我该去么?
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
Qt学习23 布局管理器(二)
Error running 'application' in idea running: the solution of command line is too long
[développement technologique - 24]: caractéristiques des technologies de communication Internet des objets existantes
JS general form submission 1-onsubmit
GoLand 2021.1.1: configure the multi line display of the tab of the open file
Qt学习22 布局管理器(一)
交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
消息订阅与发布
怎样删除对象的某个属性或⽅法
可编程逻辑器件软件测试
1px problem of mobile terminal
Dlopen() implements dynamic loading of third-party libraries
挡不住了,国产芯片再度突进,部分环节已进到4nm
Bidirectional linked list (we only need to pay attention to insert and delete functions)
Rasp implementation of PHP
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
Complete DNN deep neural network CNN training with tensorflow to complete image recognition cases