【Qt】消息对话框类
来源:互联网 发布:张孝祥javascript视频 编辑:程序博客网 时间:2024/06/10 01:55
消息对话框类在前者消息对话框的基础之上完成的
参见:http://blog.csdn.net/ldan508/article/details/51921182
【效果如下】
【添加代码】
添加新的文件msgboxdlg类
//msgboxdlg.h
<span style="font-family:Microsoft YaHei;font-size:18px;">#ifndef MSGBOXDLG_H#define MSGBOXDLG_H#include<QLabel>#include<QPushButton>#include<QGridLayout>#include<QDialog>class MsgBoxDlg : public QDialog{ Q_OBJECTpublic: MsgBoxDlg(QWidget* parent=0);private slots: void showQuestionMsg(); void showInformationMsg(); void showWarningMsg(); void showCriticalMsg(); void showAboutMsg(); void showAboutQtMsg();private: QLabel *label; QPushButton *questionBtn; QPushButton *informationBtn; QPushButton *warningBtn; QPushButton *criticalBtn; QPushButton *aboutBtn; QPushButton *aboutQtBtn; QGridLayout *mainLayout;};#endif // MSGBOXDLG_H</span>
//msgboxdlg.cpp
<span style="font-family:Microsoft YaHei;font-size:18px;">#include "msgboxdlg.h"MsgBoxDlg::MsgBoxDlg(QWidget *parent) : QDialog(parent){ setWindowTitle(tr("标注信息对话框的实例")); //设置对话框的标题 label = new QLabel; label->setText(tr("请选择一种消息框")); questionBtn = new QPushButton; questionBtn->setText(tr("QusetionMsg")); informationBtn = new QPushButton; informationBtn->setText(tr("InformationMsg")); warningBtn = new QPushButton; warningBtn->setText(tr("WarningMsg")); criticalBtn =new QPushButton; criticalBtn->setText(tr("CriticalMsg")); aboutBtn = new QPushButton; aboutBtn->setText(tr("AboutMsg")); aboutQtBtn =new QPushButton; aboutQtBtn->setText(tr("AboutQtMsg")); //布局 mainLayout =new QGridLayout(this); mainLayout->addWidget(label,0,0,1,2); mainLayout->addWidget(questionBtn,1,0); mainLayout->addWidget(informationBtn,1,1); mainLayout->addWidget(warningBtn,2,0); mainLayout->addWidget(criticalBtn,2,1); mainLayout->addWidget(aboutBtn,3,0); mainLayout->addWidget(aboutQtBtn,3,1); //事件关联 connect(questionBtn,SIGNAL(clicked(bool)),this,SLOT(showQuestionMsg())); connect(informationBtn,SIGNAL(clicked(bool)),this,SLOT(showInformationMsg())); connect(warningBtn,SIGNAL(clicked(bool)),this,SLOT(showWarningMsg()));\ connect(criticalBtn,SIGNAL(clicked(bool)),this,SLOT(showCriticalMsg())); connect(aboutBtn,SIGNAL(clicked(bool)),this,SLOT(showAboutMsg())); connect(aboutQtBtn,SIGNAL(clicked(bool)),this,SLOT(showAboutQtMsg()));}void MsgBoxDlg::showQuestionMsg(){}void MsgBoxDlg::showInformationMsg(){}void MsgBoxDlg::showWarningMsg(){}void MsgBoxDlg::showCriticalMsg(){}void MsgBoxDlg::showAboutMsg(){}void MsgBoxDlg::showAboutQtMsg(){}</span>
//dialog.h
<span style="font-family:Microsoft YaHei;font-size:18px;"> 添加头文件#include "msgboxdlg.h" 添加private成员变量: QPushButton *MsgBtn;添加类函数: MsgBoxDlg *msgDlg;添加槽函数:void showMsgDlg();</span>
//dialog.cpp
<span style="font-family:Microsoft YaHei;font-size:18px;"> 构造函数中添加: MsgBtn =new QPushButton; MsgBtn->setText(tr("标准消息对话框实例")); mainLayout->addWidget(MsgBtn,3,1); connect(MsgBtn,SIGNAL(clicked(bool)),this,SLOT(showMsgDlg()));槽函数的实现:void Dialog::showMsgDlg(){ msgDlg =new MsgBoxDlg(); msgDlg->show();}</span>
0 0
- 【Qt】消息对话框类
- QT增加消息对话框
- Qt标准对话框之消息对话框(QMessageBox)
- QT学习 之 对话框 (四) 字体对话框、消息对话框、文件对话框、进程对话框
- qt中获取打开文件路径,颜色对话框,字体对话框,自定义对话框,消息对话框,输入对话框
- 弹出消息对话框类
- QT 主窗口和非模态对话框切换 以及消息通信
- 【Qt】标准颜色对话框类
- Qt处理提示对话框类
- 消息对话框
- 消息对话框
- 消息对话框
- 消息对话框
- 消息对话框
- 常用对话框:消息对话框
- 对话框:消息对话框
- Qt对话框
- QT 对话框
- Jedis之pipeline
- git ignore file mode
- netty拆包/粘包的解决方案
- JavaScript面向对象编程
- java使用LineNumberReader读文件
- 【Qt】消息对话框类
- javaWeb验证码技术
- java 递归创建二叉树
- js刷新页面方法大全
- uva 10736 Foreign Exchange
- USACO 2.4.2 穿越栅栏
- MyEclipse快捷键大全,很实用
- 奶牛排队 (Standard IO)
- lua-string-resty的aes加密解密,无法和python的aes进行对接