QT5:第一章 初始化
2024-09-03 20:39:13
一.简介
在项目Application中:
QT Widgets Application(桌面QT应用)
QT Console Application(控制台QT应用)
QT for Python-Empty / Window(用Python开发QT应用)
QT Quick Application-Empty / Scroll / Stack /Swipe(移动平台开发QT应用)
1.Location
填一下项目名和项目地址
2.Kits
3.Details
类名(C):
基类(B):QMainWindow/QWidget/QDialog
头文件(H):
源文件(S):
创建界面(G):勾选
界面文件(F):
4.汇总
二.QMainWindow
三.QWidget
1.窗口框架
2.附加窗口
QWidget widget;
widget.setWindowTitle(QObject::tr("k5"));
widget.resize(, );
widget.move(, );
widget.show(); int x = widget.x();
qDebug("x:%d", x); int y = widget.y();
qDebug("y:%d", y);
四.QDialog
QDialog类继承与QWidget类
注意:添加hellodialog.ui文件的时候,要把里面的 <class>HelloDialog</class>
<widget class = "QDialog" name = "HelloDialog"> 改过来,不然会无法识别 ui 这个指针
1.窗口框架
// hellodialog.h #ifndef HELLODIALOG_H
#define HELLODIALOG_H #include <QDialog> namespace Ui{
class HelloDialog;
} class HelloDialog : public QDialog{ Q_OBJECT
public:
explicit HelloDialog(QWidget* parent = nullptr);
~HelloDialog(); private:
Ui::HelloDialog* ui;
}; #endif // HELLODIALOG_H
// hellodialog.cpp #include "hellodialog.h"
#include "ui_hellodialog.h" HelloDialog::HelloDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::HelloDialog)
{
ui->setupUi(this); } HelloDialog::~HelloDialog()
{
delete ui;
}
// main.cpp #include "hellodialog.h"
#include <QApplication> int main(int argc, char* argv[])
{
QApplication a(argc, argv);
HelloDialog w;
w.show(); return a.exec();
}
2.附加窗口
(1)模态对话框
QDialog* dialog = new QDialog(this);
dialog->setModal(true);
dialog->show(); QDialog dialog;
dialog.setModal(true);
dialog.show()
(2)非模态对话框
QDialog* dialog = new QDialog(this);
dialog->show(); QDialog dialog;
dialog.show()
3.对话框状态
QDialog dialog;
if (dialog.exec() == QDialog::Accepted)
最新文章
- 基础知识javascript--事件
- .Net生成HTML的三种方法
- 最大M子段和 V2
- python中的列表(list) 切片详解
- 使用CSS修改HTML5 input placeholder颜色( 转载 )
- Linux 设备模型浅析之 uevent 篇(2)
- HDU 5266 pog loves szh III (线段树+在线LCA转RMQ)
- git的使用与积累
- Aop编程--注解与xml的实现
- clob字段的值插入和查询N种方法【包括java调用存储过程传入clob参数】
- etectMultiScale(gray, 1.2,3,CV_HAAR_SCALE_IMAGE,Size(30, 30))
- canvas-7globleCompositeOperation.html
- group by 和where 条件后面不能用刚设置的别名。
- centos6启动服务说明
- setting.xml配置文件
- samba服务和nginx服务
- 运放参数的详细解释和分析-part3,输入失调电压Vos及温漂
- 11JavaScript事件
- PTA基础编程题目集6-3简单求和 (函数题)
- 软工网络15团队作业4-DAY3