close

image

image


image


#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:

1. Qt Tutorials For Beginners 6 – QMessageBox

2. Qt日期時間操作 Date and time in Qt

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(0) 人氣()