弹出对话框练习
来源:互联网 发布:设计装修房子的软件 编辑:程序博客网 时间:2024/05/16 11:48
-----------------------------------------------------------------------
#ifndef WIDGET_H#define WIDGET_H#include <QtGui/QWidget>class Widget : public QWidget{Q_OBJECT
public:
Widget(QWidget *parent = 0);~Widget();private slots:void OpenDlg();};#endif // WIDGET_H
--------------------------------------------------------------
#include "widget.h"
#include <QPushButton>
#include <QDialog>
#include <QGridLayout>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
QPushButton *quit = new QPushButton(tr("&OpenDialog"));
quit->setFont(QFont("Times", 18, QFont::Bold));
connect(quit, SIGNAL(clicked()), this, SLOT(OpenDlg()));
QGridLayout *gridLayout = new QGridLayout;
gridLayout->addWidget(quit, 0, 0);///估计从0,0位置开始
setLayout(gridLayout); ///显示出来
}
Widget::~Widget()
{
}
void Widget::OpenDlg()
{
//----弹出对话框----
QDialog * dialog = new QDialog();
dialog->setWindowTitle("A QDialog xxxWindow");
dialog->setMinimumSize(200,80);
dialog->show(); ///模态对话框
// dialog->exec(); //调出非摸态对话框
//弹出widget
QWidget* widget1= new QWidget();
widget1->setWindowTitle("1123124");
widget1->show();
//弹出MessageBox----
QMessageBox::information(this,tr("hello"),tr("Mars"));
//加载已知的ui界面
/*QUiLoader uiLoader;
QFile file("./embeddeddialog.ui");
QWidget *myWidget = uiLoader.load(&file);//如没有QtUiTools 则在.pro文件中加入 CONFIG += uitools
myWidget->show();
*/
}
模态对话框即无法转移焦点.必须关闭后方可释放焦点
"模态对话框":在Form1窗口上点击按钮弹出一个Form2窗口,在关闭Form2窗口之前,不能在Form1窗口上操作 "非模态对话框":在Form1窗口上点击按钮弹出一个Form2窗口,这个时候既可以在Form1窗口上操作,也可以在Form2窗口上操作
举例: 比如现在你在菜单里面打开页面Form: 当作模式窗体打开就用: Form frm = new Form(); frm.ShowDialog(); 而当作非模式窗体打开就用: Form frm = new Form(); frm.Show();
- 弹出对话框练习
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- 弹出对话框
- C#多线程值之APM二:GUI线程处理模式2
- C#中的一些符号,各种杂
- 快速傅氏变换之旅(五) 嵌入式中的FFT(最好选择DSP或FPGA)
- MATLAB中的worldmap函数
- 优秀博客-前端博客(转)
- 弹出对话框练习
- 从ATL中返回字符串数组到JavaScript的示例
- Oracle参数设置(10g)
- 邮件收发用什么软件
- ASM的一张体系结构简图
- vs2010 库函数问题:objidl.h(11266) : error C2061: syntax error : identifier '__RPC__out_xcount_part'
- css学习2
- Shopex的二次开发
- c++ php 扩展