当前位置: 首页>>代码示例>>C++>>正文


C++ QMessageBox::addButton方法代码示例

本文整理汇总了C++中QMessageBox::addButton方法的典型用法代码示例。如果您正苦于以下问题:C++ QMessageBox::addButton方法的具体用法?C++ QMessageBox::addButton怎么用?C++ QMessageBox::addButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMessageBox的用法示例。


在下文中一共展示了QMessageBox::addButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: maybeSave

/** 
 * maybeSave	-	some thing to do before the next operation
 *
 * @return true if all preparation has done; false if the user cancel the operation.
 */
bool MainWindow::maybeSave()
{
    if (isModified){
        // Create an warning dialog
        QMessageBox box;
        box.setWindowTitle(tr("Warning"));
        box.setIcon(QMessageBox::Warning);
        box.setText(tr("The current file %1 has been changed. Save?").arg(curFile));

        QPushButton *yesBtn = box.addButton(tr("Yes(&Y)"),
                                            QMessageBox::YesRole);
        box.addButton(tr("No(&N)"), QMessageBox::NoRole);
        QPushButton *cancelBut = box.addButton(tr("Cancel(&C)"),
                                           QMessageBox::RejectRole);

        box.exec();
        if (box.clickedButton() == yesBtn)
            return save();
        if (box.clickedButton() == cancelBut)
            return false;
    }
    return true;
}
开发者ID:KingBing,项目名称:Qt_Toys,代码行数:28,代码来源:mainwindow.cpp

示例2: closeEvent

void subMainWindow::closeEvent(QCloseEvent *)
{
    if(noSave)
    {
        QMessageBox saveWarnBox;
        saveWarnBox.setWindowTitle(tr("警告"));
        QPushButton *save = saveWarnBox.addButton(tr("保存"),QMessageBox::ActionRole);
        QPushButton *cancel = saveWarnBox.addButton(tr("不保存"),QMessageBox::ActionRole);
        saveWarnBox.setIconPixmap(tr(":/res/qt.ico"));
        saveWarnBox.setText(tr("是否保存图片?"));

        saveWarnBox.exec();

        if(save == saveWarnBox.clickedButton())
        {
            saveImage();
        }
        if(cancel == saveWarnBox.clickedButton())
        {
            return;
        }
    }
}
开发者ID:rio-2607,项目名称:image_process,代码行数:23,代码来源:submainwindow.cpp

示例3: maybeSave

bool MdiChild::maybeSave()  // 是否需要保存
{
    if (document()->isModified()) { // 如果文档被更改过
        QMessageBox box;
        box.setWindowTitle(tr("多文档编辑器"));
        box.setText(tr("是否保存对“%1”的更改?")
                    .arg(userFriendlyCurrentFile()));
        box.setIcon(QMessageBox::Warning);

        // 添加按钮,QMessageBox::YesRole可以表明这个按钮的行为
        QPushButton *yesBtn = box.addButton(tr("是(&Y)"),QMessageBox::YesRole);

        box.addButton(tr("否(&N)"),QMessageBox::NoRole);
        QPushButton *cancelBtn = box.addButton(tr("取消"),
                                               QMessageBox::RejectRole);
        box.exec(); // 弹出对话框,让用户选择是否保存修改,或者取消关闭操作
        if (box.clickedButton() == yesBtn)// 如果用户选择是,则返回保存操作的结果
            return save();
        else if (box.clickedButton() == cancelBtn) // 如果选择取消,则返回false
            return false;
    }
    return true; // 如果文档没有更改过,则直接返回true
}
开发者ID:alannet,项目名称:example,代码行数:23,代码来源:mdichild.cpp

示例4: on_m_AdjustHemisphere_clicked

void QmitkPolhemusTrackerWidget::on_m_AdjustHemisphere_clicked()
{
  int _tool = GetSelectedToolIndex();
  QMessageBox msgBox;
  QString _text;
  if (_tool == -1)
  {
    _text.append("Adjusting hemisphere for all tools.");
    msgBox.setText(_text);
    _text.clear();
    _text = tr("Please make sure, that the entire tools (including tool tip AND sensor) are placed in the positive x hemisphere. Press 'Adjust hemisphere' if you are ready.");
    msgBox.setInformativeText(_text);
  }
  else
  {
    _text.append("Adjusting hemisphere for tool '");
    _text.append(m_Controls->m_ToolSelection->currentText());
    _text.append(tr("' at port %2.").arg(_tool));
    msgBox.setText(_text);
    _text.clear();
    _text = tr("Please make sure, that the entire tool (including tool tip AND sensor) is placed in the positive x hemisphere. Press 'Adjust hemisphere' if you are ready.");
    msgBox.setInformativeText(_text);
  }

  QPushButton *adjustButton = msgBox.addButton(tr("Adjust hemisphere"), QMessageBox::ActionRole);
  QPushButton *cancelButton = msgBox.addButton(QMessageBox::Cancel);
  msgBox.exec();
  if (msgBox.clickedButton() == adjustButton) {
    // adjust
    m_TrackingDevice->AdjustHemisphere(_tool);
    MITK_INFO << "Adjusting Hemisphere for tool " << m_Controls->m_ToolSelection->currentText().toStdString();
  }
  else if (msgBox.clickedButton() == cancelButton) {
    // abort
    MITK_INFO << "Cancel 'Adjust hemisphere'. No harm done...";
  }
}
开发者ID:Cdebus,项目名称:MITK,代码行数:37,代码来源:QmitkPolhemusTrackerWidget.cpp

示例5:

void PlaneGUI::on_pushButton_2_clicked()
{
    FinalProject::UsefulFunctions useThis;
    std::string first_name = airport.selected_passenger->Get_First();
    std::string last_name = airport.selected_passenger->Get_Last();
    int age = airport.selected_passenger->Get_Age();
    int row_chosen = ui->row_chosen_2->text().toInt();
    std::string seat_chosen = ui->seat_chosen_2->text().toUtf8().constData();

    if (first_name == "" || last_name == "" || age == 0 || row_chosen == 0 || seat_chosen == "") {
        // Missing Stuff!
        cout << "Something SHitty!" << endl;
    }
    else {
        // Offer A reservation
        QMessageBox msgBox;
        msgBox.setWindowTitle("Reserve Seat");
        msgBox.setText("Are you sure you would like to reserve seat " + QString::number(row_chosen) + QString::fromStdString(seat_chosen));
        msgBox.setStandardButtons(QMessageBox::Yes);
        msgBox.addButton(QMessageBox::No);
        msgBox.setDefaultButton(QMessageBox::No);
        if(msgBox.exec() == QMessageBox::Yes){
            int row_assigned = row_chosen;
            int seat_assigned = useThis.getIntFromSeatLetter(seat_chosen) + 1;
            // do something
            if (airport.Check_For_Duplicate_Passenger(first_name,last_name,age)) {
                airport.selected_passenger = airport.Get_Duplicate_Passenger(first_name,last_name,age);

                airport.selected_flight->Add_Passenger_To_Flight(airport.selected_passenger,row_assigned,seat_assigned);

                airport.selected_flight->assigned_plane->Reserve_From_External_File(row_assigned-1, seat_assigned-1,
                                                                            airport.selected_flight->most_recently_added);
            }
            else {
                airport.selected_flight->Add_Passenger_To_Flight(first_name,last_name,age, row_assigned,
                                                            seat_assigned);
                airport.selected_flight->assigned_plane->Reserve_From_External_File((row_assigned - 1),
                                                                               (seat_assigned - 1),
                                                                               airport.selected_flight->most_recently_added);
                airport.all_passengers[airport.current_passenger_amount] = airport.selected_flight->most_recently_added; // add the most recently added passenger to the list of all passengers
                airport.current_passenger_amount++;
            }
            ui->stackedWidget->setCurrentIndex(0);
        }else {
            // do something else
            ui->stackedWidget->setCurrentIndex(0);
        }
    }
}
开发者ID:cgosiak,项目名称:AirlineFinalProject,代码行数:49,代码来源:planegui.cpp

示例6: main

int main(int argv, char **args)
{
  QApplication app(argv, args);

    QStateMachine machine;

//![0]
    QState *s1 = new QState();
    QState *s11 = new QState(s1);
    QState *s12 = new QState(s1);
    QState *s13 = new QState(s1);
    s1->setInitialState(s11);
    machine.addState(s1);
//![0]

//![2]
    s12->addTransition(quitButton, SIGNAL(clicked()), s12);
//![2]

//![1]
    QFinalState *s2 = new QFinalState();
    s1->addTransition(quitButton, SIGNAL(clicked()), s2);
    machine.addState(s2);
    machine.setInitialState(s1);

    QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit()));
//![1]

  QButton *interruptButton = new QPushButton("Interrupt Button");
  QWidget *mainWindow = new QWidget();

//![3]
    QHistoryState *s1h = new QHistoryState(s1);

    QState *s3 = new QState();
    s3->assignProperty(label, "text", "In s3");
    QMessageBox *mbox = new QMessageBox(mainWindow);
    mbox->addButton(QMessageBox::Ok);
    mbox->setText("Interrupted!");
    mbox->setIcon(QMessageBox::Information);
    QObject::connect(s3, SIGNAL(entered()), mbox, SLOT(exec()));
    s3->addTransition(s1h);
    machine.addState(s3);

    s1->addTransition(interruptButton, SIGNAL(clicked()), s3);
//![3]

  return app.exec();
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:49,代码来源:main2.cpp

示例7: stopPressed

void TimeLapseWidget::stopPressed() {

    stopShooting();

    // Only ask about the movie if there are any pictures to make into a movie
    if (numPics>0) {
        QMessageBox msgBox;
        msgBox.setText(tr("%1 images were taken before \"Stop\" was pressed.\n").arg(numPics));
        msgBox.setInformativeText(tr("Do you want to make a movie with these images?"));

        // msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        QPushButton *yesButton = msgBox.addButton(QMessageBox::Yes);
        msgBox.addButton(QMessageBox::No);
        QPushButton *noAndDeleteButton = msgBox.addButton(tr("No, and delete images"), QMessageBox::ActionRole);

        msgBox.exec();

        if (msgBox.clickedButton() == yesButton) {
            makeMovie();
        } else if (msgBox.clickedButton() == noAndDeleteButton) {
            removeImages();
        }
    }
}
开发者ID:jl2,项目名称:QT-Canon,代码行数:24,代码来源:timelapsewidget.cpp

示例8: delete_clicked

void MainWindow::delete_clicked()
{
    QString tk_id;
    if (current_tab==2)
    {
        //tk_id=tasks_model->data(tasks_model->index(ui->tableView->currentIndex().row(),0)).toString();
    //else
        tk_id=tasks_full_model->data(tasks_full_model->index(ui->tableView_2->currentIndex().row(),0)).toString();

    QMessageBox m;
    m.setText(trUtf8("Θέλετε να διαγράψετε την επιλεγμένη κίνηση"));
    m.setInformativeText(trUtf8("ΠΡΟΣΟΧΗ!!!"));
    QAbstractButton *acc = m.addButton(trUtf8("Ναί"),
                    QMessageBox::ActionRole);
    QAbstractButton *rej = m.addButton(trUtf8("Όχι"), QMessageBox::ActionRole);

    m.move(100, 100);
    QFont serifFont("Times", 18, QFont::Bold);
    m.setFont(serifFont);
    m.setDefaultButton((QPushButton*)rej);

    m.exec();
    if (m.clickedButton() == rej)
        return;

    if (m.clickedButton() == acc)
    {
        QSqlQuery query(db1);
        //qDebug()<<"TID"<<tk_id;
        query.exec("delete from tasks where id="+tk_id);
    }
    refresh_tasks();
    refresh_full_tasks();
    ui->pushDelete->setEnabled(FALSE);
    }
}
开发者ID:algogr,项目名称:hourglass,代码行数:36,代码来源:mainwindow.cpp

示例9: on_commitButton_clicked

void Widget::on_commitButton_clicked()
{
    QString name = ui->cnameLineEdit->text();
    QString sex = ui->cmaleRadioButton->isChecked() ? tr("男") : tr("女");
    QString id = ui->cidLineEdit->text();
    QString phone = ui->cphoneLineEdit->text();
    QString checkintime = ui->ccheckintimeDateEdit->text();

    QList<QTableWidgetItem*> items = ui->orderRoomTableWidget->selectedItems();
    QStringList roomnos;
    foreach (QTableWidgetItem * item, items)
    {
        roomnos << item->text();
    }

    if (name.isEmpty() || id.length() != 18 || phone.length() != 11)
    {
        QMessageBox::information(this, tr("预定管理"), tr("用户信息不完整"));
    }
    else if (items.isEmpty())
    {
        QMessageBox::information(this, tr("预定管理"), tr("没有选定预定房间"));
    }
    else
    {
        QString roomno;
        foreach (QString str, roomnos)
        {
            roomno += str + " ";
        }

        QString text = tr("姓名:") + name + tr("\n性别:") + sex + tr("\n身份证号:") + id +
                       tr("\n联系电话:") + phone + tr("\n预定入住时间:") + checkintime +
                       tr("\n预定的房号:") + roomno;
        QMessageBox box;
        box.setWindowTitle(tr("信息确认"));
        box.setText(text);
        box.addButton(tr("确定"), QMessageBox::AcceptRole);
        box.addButton(tr("取消"), QMessageBox::RejectRole);


        if (box.exec() == QMessageBox::AcceptRole)
        {
            // ## 提交成功,将信息录入数据库,同时,更新此界面
            dealOrderPage();
            resetOrderPage();
        }
    }
开发者ID:Mr-Phoebe,项目名称:QT-learning,代码行数:48,代码来源:Reserve.cpp

示例10: about

void MainWindow::about(){
    QMessageBox msgBox;
    msgBox.setWindowTitle("About");
    msgBox.addButton(QMessageBox::Ok);
    msgBox.setText("<p align='center'>Binary Decision Diagram(BDD)<br>"
                        "Version 0.1<br>"
                        "By Ali Diouri<br>"
                      "[email protected]<br>"
               "Licensed under BSD 3-Clause License</p>");
    msgBox.setIcon(QMessageBox::Information);
    int selection = msgBox.exec();
    if(selection == QMessageBox::Yes) {
        this->activateWindow();
        lineEdit->setFocus();
    }
}
开发者ID:theshadowx,项目名称:qtbdd,代码行数:16,代码来源:mainwindow.cpp

示例11: on_cancel_flight_clicked

void PlaneGUI::on_cancel_flight_clicked()
{
    QMessageBox msgBox;
    msgBox.setWindowTitle("Cancel Flight");
    msgBox.setText("Are you sure you would like to cancel this flight?");
    msgBox.setStandardButtons(QMessageBox::Yes);
    msgBox.addButton(QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::No);
    if(msgBox.exec() == QMessageBox::Yes){
        // do something
        airport.Return_Flight();
        ui->stackedWidget->setCurrentIndex(0);
    }else {
        // do something else
    }
}
开发者ID:cgosiak,项目名称:AirlineFinalProject,代码行数:16,代码来源:planegui.cpp

示例12: delete_attempt

void Cmap_button::delete_attempt()
{
    QMessageBox msg;
    msg.setText( tr( "Are you really sure that you want to delete " )
                 + this->text + tr( " ?" ) );
    msg.addButton( tr( "Delete" ), QMessageBox::AcceptRole );
    msg.addButton( tr( "Cancel" ), QMessageBox::RejectRole );
    if ( msg.exec() == QDialog::Rejected )
    {
        //remove map files
        QFile f;
        f.remove( this->absolute_map_path );
        f.remove( this->absolute_map_path + ".preview" );
    }

    QTimer::singleShot( 500, this, SIGNAL(please_refresh_as_we_deleted_something()) );
}
开发者ID:axed,项目名称:gnurpgm,代码行数:17,代码来源:cmap_array_widget.cpp

示例13: execCmdList

int MainWindow::execCmdList(QDomElement node)
{
    QMessageBox info;
    info.addButton(QMessageBox::Ok);
    info.setText(("开始进行系统备份,请按照提示执行"));
    info.exec();
    QString cmd,errorString;
    int cmdType = 0,errorCheckType=0,timeOut=0;
//    QStringList par;
//    par<<"";
    int checkValue;
    while(!node.isNull()){
        cmd = node.attributeNode("cmd").nodeValue();
        errorString = node.attributeNode("errorString").nodeValue();
        cmdType = node.attributeNode("type").nodeValue().toInt();
        errorCheckType = node.attributeNode("errorCheckType").nodeValue().toInt();
        timeOut = node.attributeNode("timeOut").nodeValue().toInt();
        node = node.nextSiblingElement();
        qDebug()<<cmd <<errorString<<cmdType<<errorCheckType<<timeOut;
        switch(cmdType){
        case 1:
            qDebug()<<"cmd-->" << cmd;
 //           this->pointer->waitForFinished(timeOut*1000);
            this->pointer->start(cmd);
            this->pointer->waitForFinished(timeOut*1000);
            checkValue = this->checkError(errorCheckType,&errorString);
            if(checkValue < 0){
                return checkValue;
            }
            break;
        case 2:
            qDebug()<<"status :"<<cmd;
            break;
        case 3:
            info.setText((cmd));
            info.exec();
            break;
        case 4:

            break;
        default:
            break;
        }
    }
    return 1;
}
开发者ID:godvmxi,项目名称:mobile,代码行数:46,代码来源:mainwindow.cpp

示例14: confirmDeleteImage

bool ClosableImage::confirmDeleteImage()
{
    if (Settings::instance()->dontShowDeleteImageConfirm())
        return true;

    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Question);
    msgBox.setWindowTitle(tr("Really delete image?"));
    msgBox.setText(tr("Are you sure you want to delete this image?"));
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    QCheckBox dontPrompt(QObject::tr("Do not ask again"), &msgBox);
    dontPrompt.blockSignals(true);
    msgBox.addButton(&dontPrompt, QMessageBox::ActionRole);
    int ret = msgBox.exec();
    if (dontPrompt.checkState() == Qt::Checked && ret == QMessageBox::Yes)
        Settings::instance()->setDontShowDeleteImageConfirm(true);
    return (ret == QMessageBox::Yes);
}
开发者ID:hathagat,项目名称:MediaElch,代码行数:18,代码来源:ClosableImage.cpp

示例15: on_aceptar_clicked

void AgregarCarga::on_aceptar_clicked()
{
    if(ui->deposito->isChecked())
        guardar();
    else
    {
        qlonglong cliente = ui->cliente->itemData(ui->cliente->currentIndex()).toLongLong();
        int grano = ui->grano->itemData(ui->grano->currentIndex()).toInt();

        if(!chequearCompra(cliente, grano) && validarCarga())
        {
            // PREGUNTAR SI SE QUIERE REALIZAR CONTRATO DE COMPRA
            QMessageBox msgBox;
            QString message = "No existe contrato de compra para ";
            message.append(ui->cliente->currentText());
            message.append(". Desea crear un nuevo contrato?");
            msgBox.setText(message);
            msgBox.setWindowTitle("Nueva Carga");
            msgBox.addButton("Aceptar", QMessageBox::YesRole);
            msgBox.addButton("Cancelar", QMessageBox::NoRole);
            msgBox.setIcon(QMessageBox::Question);

            int ret = msgBox.exec();
            int exits;
            ConcretarOfrecido *nuevacompra = new ConcretarOfrecido();

            switch(ret){
                case 0:
                    exits = nuevacompra->nuevaCompra(cliente,grano);
                    if(exits)
                        guardarYcalzar();
                    else
                        QMessageBox::warning(0, QObject::tr("Error"),"Ha ocurrido un error, por favor intentelo de nuevo.");
                    break;
                 case 1:
                    guardarYcalzar();
                break;
            }
        }
        else
           guardarYcalzar();

    }
}
开发者ID:rockols,项目名称:acopio,代码行数:44,代码来源:agregarcarga.cpp


注:本文中的QMessageBox::addButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。