弹出对话框练习
2012-05-11 14:39
127 查看
-----------------------------------------------------------------------
#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(); |
相关文章推荐
- 实现了弹出DIV对话框[原]
- 利用js在asp.net中验证是否重复弹出对话框并导向网址
- 当点击登录的时候,弹出一个对话框,让你写用户名和密码
- js将页面table导出excel,弹出保存对话框
- win7 64位系统 开机登录后 黑屏+仅有鼠标 弹出对话框“无法找到脚本文件c:\windows\run.vbs”
- js弹出对话框的方法总结
- Coolite 服务器端弹出对话框
- asp.net 点击一个按钮弹出对话框选择文件然后选择文件完成之后就自动上传文件 input(file)
- Swing中弹出对话框的几种方式
- SweetAlert简单使用,弹出对话框
- Android实现底部对话框BottomDialog弹出实例代码
- 弹出对话框
- jQuery实现遮罩弹出对话框(仿天猫的删除对话框)
- 弹出一个IE的下载对话框
- CSDN新的IM竟然不断的自动弹出对话框哦!
- 在服务程序中弹出对话框
- 调用DocumentProperties弹出打印设置对话框
- FckEditor中从word文档粘贴过来的内容在点击确定清除格式后直接清除而不是再弹出从MS WORD粘贴对话框
- symbian 弹出系统自定义对话框,可以修改左右软件名称
- Android 点击按钮弹出ListView对话框