当前位置:网站首页>Multi interface switching in one UI of QT
Multi interface switching in one UI of QT
2022-06-26 07:44:00 【Bright moon drunk windowsill】
QT Many interface exchanges
Environmental Science :VS2019+QT_tools
I checked many great God's posts on the Internet , Firstly, the methods of multi interface switching are summarized as follows :
1. Can pass QT Designer Add Containers Control Stacked Widget To achieve the same UI Page switching in , You can use the right mouse button or code to increase or decrease pages
2. You can create multiple UI file , Then set and select one of the displays , Other hidden implementations are different UI Interface switching , This method csdn There are many posts on , I won't go into details here .
3. Another way is to combine the above two methods , Insert... In the main window at the same time Stacked Widget, And create multiple UI file , then UI Files are added to the main window as spaces Stacked Widget in , Realize the interface switching in the same window , The advantage of this method is that different UI Editing without too much confusion , More efficient .
1. Main window insert Stacked Widget
VS Find your main window in Ui file , Double click to open and enter Designer
When finished, select the form above -> Look at the code -> preservation -> close
// The call example is as follows :
ui.stackedWidget->addWidget(A);
ui.stackedWidget->addWidget(B);
2. Innovate multiple Ui file
Right click on the item , Add new item 
Ui Attribute selection QWidget
After successful creation, there will be more in the solution 3 File :.cpp、 .h、 .ui
3. Multi interface switching
main window .h
#pragma once
#include <QtWidgets/QMainWindow>
#include"calibration.h"// Two new UI
#include"camerror.h"
#include "ui_Cameraparameter.h"
class Cameraparameter : public QMainWindow
{
Q_OBJECT
public:
Cameraparameter(QWidget *parent = nullptr);
~Cameraparameter();
private:
Ui::CameraparameterClass ui;
calibration* ui_cal;
camerror* ui_error;
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
};
main window .cpp
#include "Cameraparameter.h"
Cameraparameter::Cameraparameter(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
// Apply for two new interfaces
ui_cal = new calibration;
ui_error = new camerror;
// Add interface to stackedWidget Control
ui.stackedWidget->addWidget(ui_cal);
ui.stackedWidget->addWidget(ui_error);
}
Cameraparameter::~Cameraparameter()
{
}
void Cameraparameter::on_pushButton_clicked()
{
ui.stackedWidget->setCurrentIndex(2);
}
void Cameraparameter::on_pushButton_2_clicked()
{
ui.stackedWidget->setCurrentIndex(3);
}
Effect display :
边栏推荐
- Qt基础教程:QString
- 多传感器融合感知
- [UVM practice] Chapter 3: UVM Fundamentals (3) field automation mechanism
- Apache inlong graduated as a top-level project with a million billion level data stream processing capability!
- Kalman filter_ Recursive Processing
- systemctl php配置文件
- php array_ Merge details
- How to define a digital factory and what is the relationship with smart factory and industry 4.0
- QT basics tutorial: qstring
- QTreeWidget And QTableWidget
猜你喜欢

MXNet对NIN网络中的网络的实现

Google Earth Engine(GEE) 02-基本了解和学习资源

OSPF design principles, commands take H3C as an example

Teach you how to use the harmonyos local simulator

Mxnet implementation of network in Nin network

Jemter 压力测试 -基础请求-【教学篇】

How to design API return codes (error codes)?

How to define a digital factory and what is the relationship with smart factory and industry 4.0

Tsinghua Yaoban chendanqi won Sloan award! He is a classmate with last year's winner Ma Tengyu. His doctoral thesis is one of the hottest in the past decade

执行npm install -g serve时报错权限权限问题解决方案
随机推荐
Item2 installation configuration and environment failure solution
Record the dependent installation problems encountered in building the web assets when developing pgadmin
Nine hours, nine people and nine doors (01 backpack deformation) - Niuke
Solution to the problem of multi application routing using thinkphp6.0
Yyds dry inventory Druid connection pool usage
The long path of Xiao Sha (graph theory, Euler diagram)
Error: the specified LINQ expression contains a reference to a query associated with a different context
You can command Siri without making a sound! The Chinese team of Cornell University developed the silent language recognition necklace. Chinese and English are OK
How MySQL implements the RC transaction isolation level
Installation homebrew error summary
Go language custom DNS resolver practice yyds dry inventory
This article will take you to learn in detail what is FTTH
JS event loop mechanism
指南针炒股软件开户是合法的吗?安全吗
[UVM practice] Chapter 3: UVM Fundamentals (3) field automation mechanism
Redis(5)----浅谈压缩列表
The difference between insert ignore and insert into
Take you three minutes to get started typescript
Tsinghua Yaoban chendanqi won Sloan award! He is a classmate with last year's winner Ma Tengyu. His doctoral thesis is one of the hottest in the past decade
My colleague asked a question I never thought about. Why did kubernetes' superfluous' launch the static pod concept?