Qt 设置对话框中按钮

Qt 设置对话框中按钮

ID:37896469

大小:63.00 KB

页数:4页

时间:2019-06-02

Qt 设置对话框中按钮_第1页
Qt 设置对话框中按钮_第2页
Qt 设置对话框中按钮_第3页
Qt 设置对话框中按钮_第4页
资源描述:

《Qt 设置对话框中按钮》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Qt对话框及其按钮本文应该说主要是讲述Qt按钮的一些设置方法,主要内容为:标准按钮的创建、自设按钮、按钮文本的中英文显示、按钮的禁用、设置按钮大小、按钮的透明设置、默认按钮、按钮上图标加载、对话框上显示中英文文本、对话框标题等。程序中已给出解释:首先:.h文件#ifndefMESSAGEBOX_H#defineMESSAGEBOX_H#includeclassQLabel;classMessageBox:publicQDialog{Q_OBJECTpublic:MessageBox(QWidget*parent=0);pub

2、licslots:voidslotQuestion();voidslotInformation();voidslotWarning();voidslotCritical();voidslotAbout();voidslotAboutQt();voidslotCustom();private:QLabel*label;};#endif//MESSAGEBOX_H其次:.cpp文件#include"messagebox.h"#includeMessageBox::MessageBox(QWidget*parent):QDialog(

3、parent){setWindowTitle(trUtf8("345257271350257235346241206345255246344271240347244272344276213"));label=newQLabel;QPushButton*btn1=newQPushButton(this);btn1->setText(trUtf8("347226221351227256"));//显示按钮中文名称QPushButton*btn2=newQPushButton("this");b

4、tn2->setText(trUtf8("344277241346201257"));QPushButton*btn3=newQPushButton("this");btn3->setText(trUtf8("346217220351206222"));QPushButton*btn4=newQPushButton("Critical");//按钮名称为英文QPushButton*btn5=newQPushButton("About");QPushButton*btn6=newQPushButton("AboutQt"

5、);QPushButton*btn7=newQPushButton("Custom");QGridLayout*grid=newQGridLayout;grid->addWidget(btn1,0,0);grid->addWidget(btn2,0,1);grid->addWidget(btn3,1,0);grid->addWidget(btn4,1,1);grid->addWidget(btn5,2,0);grid->addWidget(btn6,2,1);grid->addWidget(btn7,3,0);QVBoxLayout*main

6、Layout=newQVBoxLayout;mainLayout->setMargin(10);mainLayout->setSpacing(20);mainLayout->addWidget(label);mainLayout->addLayout(grid);setLayout(mainLayout);connect(btn1,SIGNAL(clicked()),this,SLOT(slotQuestion()));connect(btn2,SIGNAL(clicked()),this,SLOT(slotInformation()));c

7、onnect(btn3,SIGNAL(clicked()),this,SLOT(slotWarning()));connect(btn4,SIGNAL(clicked()),this,SLOT(slotCritical()));connect(btn5,SIGNAL(clicked()),this,SLOT(slotAbout()));connect(btn6,SIGNAL(clicked()),this,SLOT(slotAboutQt()));connect(btn7,SIGNAL(clicked()),this,SLOT(slotCus

8、tom()));}voidMessageBox::slotCustom(){QMessageBoxcustomMsgBox;customMsgBox.setWind

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。