1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
// .h
class WaitDialog : public QDialog {
public:
WaitDialog(uint interval, QWidget *p=0);
int exec();
private:
QTimer timer;
};
// .cpp
WaitDialog::WaitDialog(uint interval, QWidget *p) : QDialog(p)
{
QVBoxLayout *l = new QVBoxLayout(this);
QLabel *lab = new QLabel("Please wait");
l->addWidget(lab);
setLayout(l);
timer.setSingleShot(true);
timer.setInterval(interval);
connect(&timer, SIGNAL(timeout()), this, SLOT(accept()));
}
int WaitDialog::exec()
{
timer.start();
return QDialog::exec();
} |