定时关闭消息对话框
2014-12-04 20:34
471 查看
class QTimeDialog : public QDialog
{public:
QTimeDialog (const QString & str,QWidget *parent = NULL);
~QTimeDialog ();
static void show(const QString & msg, QWidget *parent = NULL);
protected:
void startShow();
virtual void timerEvent(QTimerEvent * event);
private:
QLabel * m_display;
QHBoxLayout * m_layout;
QString m_msg;
int m_timeCount;
int m_timerId;
static QTimeDialog * _timeDialg_;
};
{public:
QTimeDialog (const QString & str,QWidget *parent = NULL);
~QTimeDialog ();
static void show(const QString & msg, QWidget *parent = NULL);
protected:
void startShow();
virtual void timerEvent(QTimerEvent * event);
private:
QLabel * m_display;
QHBoxLayout * m_layout;
QString m_msg;
int m_timeCount;
int m_timerId;
static QTimeDialog * _timeDialg_;
};
//
#define MAX_MSG_SHOW 60
//----------------------------------------------------------------------------------
QTimeDialog *::QTimeDialog _timeDialg_ = NULL;
//-----------------------------------------------------------------------------
QTimeDialog ::(QTimeDialog const QString & str, QWidget *parent)
:m_msg(str)
,QDialog(parent)
,m_timeCount(0)
,m_timerId(0)
{
m_display = new QLabel;
m_layout = new QHBoxLayout;
m_layout->addWidget(m_display);
this->setLayout(m_layout);
}
QTimeDialog ::~QTimeDialog()
{
this->killTimer(m_timerId);
_timeDialg_ = NULL;
}
void QTimeDialog::show(const QString & msg,QWidget * parent)
{
if(_timeDialg_)
{
_timeDialg_->m_timeCount = 0;
_timeDialg_->m_display->setText(msg);
}
else
{
_timeDialg_ = new GZLTimeDialog(msg,parent);
_timeDialg_->startShow();
}
}
void QTimeDialog::timerEvent(QTimerEvent * event)
{
m_timeCount++;
if(m_timeCount > MAX_MSG_SHOW)
{
m_timeCount = 0;
this->close();
}
}
void QTimeDialog::startShow()
{
QDialog::show();
m_timerId = this->startTimer(1000);
}
相关文章推荐
- 定时自动关闭的消息对话框(效果同msgbox)
- MFC应用程序中处理消息,创建窗口的过程,关闭窗口(非模态窗口),打开模式对话框等的函数调用顺序
- 关闭对话框时的消息响应
- 显示对话框之后定时关闭该对话框
- Android对话框定时自动关闭的实现
- Android,对话框定时自动关闭的实现
- MFC应用程序中处理消息的顺序以及对话框关闭步骤
- VC 定时自动关闭MessageBox弹出对话框
- MFC应用程序中处理消息,创建窗口的过程,关闭窗口(非模态窗口),打开模式对话框等的函数调用顺序 .
- 定时关闭的消息提示框
- 对话框关闭时的消息处理
- 定时关闭的对话框窗口
- 转:关于定时关闭询问对话框的一点体会
- VC中如何让子对话框响应最大化、最小化、关闭等系统消息
- MFC 关闭对话框时的WM_CLOSE消息响应
- mc_PopupBox 弹出可定时自动关闭的消息窗口
- MFC对话框Enter键、Esc键、关闭按钮的消息处理
- 创建可以定时自动关闭的对话框
- VC 定时自动关闭MessageBox弹出对话框 (2010-12-15 15:28:06)转载▼
- 显示消息提示对话框,关闭当前窗口,刷新父窗口