close
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QTime>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QMessageBox::about(this, "About", "This is an about dialog");
}
void MainWindow::on_pushButton_2_clicked()
{
QMessageBox::aboutQt(this, "Something about QT");
}
void MainWindow::on_pushButton_3_clicked()
{
QMessageBox::critical(this,"Error occured","You should check out what happened!");
}
void MainWindow::on_pushButton_4_clicked()
{
QTime dt_now = QTime::currentTime();
QMessageBox::information(this, "Current Time: ", dt_now.toString());
}
void MainWindow::on_pushButton_5_clicked()
{
QMessageBox::StandardButton reply = QMessageBox::question(this, "Login","Are you ready to go?",
QMessageBox::Yes | QMessageBox::No);
if(reply == QMessageBox::Yes)
{
QMessageBox::information(this, "Yes", "You've selected 'Yes' button");
qDebug() << "Yes is clicked" << endl;
}else if(reply == QMessageBox::No)
{
QMessageBox::information(this, "No", "You've selected 'No' button");
qDebug() << "No is clicked" << endl;
}
}
void MainWindow::on_pushButton_6_clicked()
{
QMessageBox::warning(this, "Warning","Some warning messages have occured!");
}
Reference:
全站熱搜
留言列表