当前位置:网站首页>QT: modal, modeless, text box, button, single line input box
QT: modal, modeless, text box, button, single line input box
2022-07-26 07:15:00 【@Bu Xiangwan spicy】
One 、 Modal, non modal
#include "widget.h"
#include <QApplication>
#include <QDialog>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
QDialog dia(&w);
QLabel lab("Hello",&w);
lab.setGeometry(100,300,200,100);
QObject::connect(&but,&QPushButton::clicked,&lab,&QLabel::clear);
lab.setStyleSheet("font:25px;color:blue");
lab.setText("<a href = www.baidu.com> use Baidu Search ");
lab.setToolTip(" Show me URL");
lab.setToolTipDuration(1000);
QObject::connect(&lab,&QLabel::linkActivated,&lab,&QLabel::clear);
QObject::connect(&lab,&QLabel::linkActivated,&lab,&QLabel::setText);
dia.setModal(true);
dia.show();
dia.exec();
w.show();
return a.exec();
} Two 、 The text box
#include "widget.h"
#include <QApplication>
#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
QLabel lab(&w);
lab.setText("Hello Qt");
lab.setGeometry(50,100,150,100);
lab.setStyleSheet("font:20px;color:blue");
lab.move(300,200);
lab.setText("<a href = \"www.baidu.com\"> Baidu ");
lab.setToolTip(" Click to display URL");
lab.setToolTipDuration(1000);
QObject::connect(&lab,&QLabel::linkActivated,&lab,&QLabel::setText);
w.show();
return a.exec();
}
3、 ... and 、 Button
#include "widget.h"
#include <QApplication>
#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
QPushButton but1(" close ",&dia);
but1.move(10,10);
but1.show();
but1.setAutoDefault(false);
QObject::connect(&but1,&QPushButton::clicked,&dia,&QDialog::close);
w.show();
return a.exec();
}
Four 、 Single line input box
#include "widget.h"
#include <QApplication>
#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
QLineEdit ed(&w);
ed.move(100,200);
ed.setPlaceholderText(" Please enter ...");
ed.setClearButtonEnabled(true);
ed.setEchoMode(QLineEdit::Password);
QLabel lab(&w);
lab.move(100,100);
QObject::connect(&ed,&QLineEdit::textChanged,&lab,&QLabel::setText);
w.show();
return a.exec();
}边栏推荐
- Depth cloning and reflection of typescript class objects
- Tips when entering a formula in latex
- Opencv learning warp Perspective
- Curl post request on the server, using postman tool for parameter conversion
- MySQL execution plan
- Weekly tip 142: multi parameter constructors and explicit
- 20220725 convolution in automatic control principle
- Basic operations and common functions of MySQL table creation
- Common CMD instructions
- 数据平台调度升级改造 | 从Azkaban 平滑过度到 Apache DolphinScheduler 的操作实践
猜你喜欢

Screen: frame paste, 0 fit, full fit

Apache dolphin scheduler & tidb joint meetup | focus on application development capabilities under the development of open source ecosystem

又是一年开源之夏,1.2万项目奖金等你来拿!

基于C51实现led流水灯

Flame diagram analysis Flink backpressure

从XSS Playload 学习浏览器解码

Queue assistant | product update log in June 2022

What are the basics of getting started with spot silver
![[database] CTE (common table expression)](/img/36/812026995f5d0b64d26f1667638010.png)
[database] CTE (common table expression)

成为 Apache 贡献者,So easy!
随机推荐
Opencv learning color detection
Apache dolphin scheduler & tidb joint meetup | focus on application development capabilities under the development of open source ecosystem
每周小贴士#142:多参数构造函数和explicit
IR tool in JIT and download, compile and use of jitwatch
Opengauss simple version installation error
Become an Apache contributor, so easy!
[database] CTE (common table expression)
Why can't extern compile variables decorated with const?
Question: can't download sh shellcheck Please install it manually and some commands of shell script
10 papers of ant security laboratory were included by ccf-a top meeting to explore the realization of AI credibility from the perspective of algorithm
"Wei Lai Cup" 2022 Niuke summer multi school training camp 1 supplementary question record (acdgij)
Business secret series -- Talking about the evaluation of commercial passwords from the perspective of Party A and Party B (I)
Drools (2): drools quick start
Airiot IOT platform enables the container industry to build a welding station information monitoring system
RGB-T追踪——【数据集基准】GTOT / RGBT210 / RGBT234 / VOT-2019-2020 / LasHeR / VTUAV
Data platform scheduling upgrade and transformation | operation practice from Azkaban smooth transition to Apache dolphin scheduler
Talent column | can't use Apache dolphin scheduler? The most complete introductory tutorial written by the boss in one month [3]
centos7下的MySQL57版本,遇到一个问题不理解有知道的大shen告知
Opencv learning warp Perspective
基于C51实现led流水灯