启动一个对话框后,过一段时间自行关闭销毁
ReminderWidget::ReminderWidget(QString text, QWidget* parent)
: QWidget(parent)
{
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint);
this->setAttribute(Qt::WA_DeleteOnClose);
QTimer* timer = new QTimer(this);
timer->start(1500);
timer->setSingleShot(true);
connect(timer, SIGNAL(timeout()), this, SLOT(onTimeupDestroy()));
}
ReminderWidget::~ReminderWidget() {}
void ReminderWidget::onTimeupDestroy()
{
this->close();
}
class ReminderWidget : public QWidget
{
Q_OBJECT
public:
ReminderWidget(QString text="",QWidget *parent = Q_NULLPTR);
~ReminderWidget();
private slots:
void onTimeupDestroy();
};
ReminderWidget* p_widget = new ReminderWidget("test");
p_widget->exec();
QMessageBox msgBox(QMessageBox::Information, "Wait", "Wait for view init.", QMessageBox::Yes|QMessageBox::No);
msgBox.button(QMessageBox::Yes)->animateClick(1);
QMessageBox *m_box = new QMessageBox(QMessageBox::Information,QString("111"),QString("111"));
QTimer::singleShot(1000,m_box,SLOT(accept()));