是的,直接用QMessageBox是模态的,看来是对话框的问题,不是父窗口的问题。
上代码:
New_Dialog.h
//////////////////////////////////////////
#ifndef NEW_DIALOG_H
#define NEW_DIALOG_H
#include <QDialog>
#include "New_Button.h"
class New_Dialog : public QDialog
{
Q_OBJECT
public:
New_Dialog(QWidget *parent = 0);
~New_Dialog();
protected:
void paintEvent(QPaintEvent *);//这个在窗口需要重绘的时候自动调用
private:
QPixmap backgroundImage;
New_Button *OKButton;
};
#endif // NEW_DIALOG_H
New_Dialog.cpp
////////////////////////////////////////////////////////////
#include "New_Dialog.h"
#include <QtGui>
New_Dialog::New_Dialog(QWidget *parent/*,QString information*/)
: QDialog(parent)
{
//ui.setupUi(this);
//设置窗体没有边框
setWindowFlags(Qt::FramelessWindowHint);
//设置背景图片
backgroundImage.load(":/Application/informationDialog.png");
resize(backgroundImage.size());
setMask(QBitmap(backgroundImage.mask()));
OKButton=new New_Button(this,":/Application/OK.png");
OKButton->setGeometry(214,230,OKButton->width(),OKButton->height());
connect(OKButton,SIGNAL(clicked()),this,SLOT(accept()));
move(200,150);
}
New_Dialog::~New_Dialog()
{
}
void New_Dialog::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.drawPixmap(0,0,backgroundImage);
}
//////////////////////////////////////////////////////////////
请帮忙分析一下是什么问题,谢谢!