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


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

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


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

示例1: deniedEvent

int MainWindow::deniedEvent(QString &login){
    QMessageBox* note =
        new QMessageBox(QMessageBox::Information, tr("The application was not accepted"),
                        login + tr(" has not received your application."),
                        QMessageBox::Retry|QMessageBox::Cancel);
    note->addButton(tr("Delete"), QMessageBox::ApplyRole);

    int result = note->exec();
    qDebug() << result << note->clickedButton() << note->buttonRole(note->clickedButton());
    delete note;
    switch(note->buttonRole(note->clickedButton())){
        case QMessageBox::AcceptRole:
            return account.friendRequest(login, contact_action::add).statusCode;
        case QMessageBox::RejectRole:
            break;
        case QMessageBox::ApplyRole:
            return on_DeleteContactButton_clicked();
        default: break;
    }
    return 0;
}
开发者ID:olegrok,项目名称:Messenger,代码行数:21,代码来源:mainwindow.cpp

示例2: acceptNavigationRequest

bool QtWebKitWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type)
{
	if (request.url().scheme() == QLatin1String("javascript") && frame)
	{
		frame->evaluateJavaScript(request.url().path());

		return true;
	}

	if (type == QWebPage::NavigationTypeFormResubmitted && SettingsManager::getValue(QLatin1String("Choices/WarnFormResend")).toBool())
	{
		QMessageBox dialog;
		dialog.setWindowTitle(tr("Question"));
		dialog.setText(tr("Are you sure that you want to send form data again?"));
		dialog.setInformativeText("Do you want to resend data?");
		dialog.setIcon(QMessageBox::Question);
		dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
		dialog.setDefaultButton(QMessageBox::Cancel);
		dialog.setCheckBox(new QCheckBox(tr("Do not show this message again")));

		bool cancel = false;

		if (m_webWidget)
		{
			dialog.setModal(false);

			QEventLoop eventLoop;

			m_webWidget->showDialog(&dialog);

			connect(&dialog, SIGNAL(finished(int)), &eventLoop, SLOT(quit()));
			connect(this, SIGNAL(destroyed()), &eventLoop, SLOT(quit()));

			eventLoop.exec();

			m_webWidget->hideDialog(&dialog);

			cancel = (dialog.buttonRole(dialog.clickedButton()) == QMessageBox::RejectRole);
		}
		else
		{
开发者ID:Kermit,项目名称:otter,代码行数:41,代码来源:QtWebKitWebPage.cpp

示例3: deleteCurrentPlot

void plotsDialog::deleteCurrentPlot()
{
    QMessageBox * askBox = new QMessageBox(this);
    askBox->addButton("Delete",QMessageBox::YesRole);
    askBox->addButton("Cancel",QMessageBox::NoRole);
    askBox->setText("Confirm to delete the plot?");
    askBox->setWindowTitle("Warning");
    askBox->exec();
    if(askBox->buttonRole(askBox->clickedButton())==QMessageBox::YesRole)
    {
        Plot* plotToDelete = dynamic_cast<Plot*>(tabs->currentWidget());
#ifdef Q_OS_WIN32
        QFile file("plotTemp.xml");
#endif
#ifdef Q_OS_MAC
        QDir dir = qApp->applicationDirPath();
        /*dir.cdUp();*/
        /*dir.cdUp();*/
        /*dir.cdUp();*/
        QString bundleDir(dir.absolutePath());
        QFile file(bundleDir+"/plotTemp.xml");
#endif
        if(!file.open(QIODevice::ReadWrite|QIODevice::Text))
        {
            return;
            globalpara.reportError("Fail to open xml file for plots!",this);
        }
        else
        {
            QDomDocument doc;
            QTextStream stream;
            stream.setDevice(&file);
            if(!doc.setContent(&file))
            {
                globalpara.reportError("Fail to load xml document for plots!",this);
                file.close();
                return;
            }
            else
            {
                QDomElement plotData = doc.elementsByTagName("plotData").at(0).toElement();
                plotData.removeChild(plotData.elementsByTagName(tabs->tabText(tabs->currentIndex())).at(0));
            }
            file.resize(0);
            doc.save(stream,4);
            file.close();
            stream.flush();
        }


        if(tabs->count()>1)
        {
            tabs->removeTab(tabs->currentIndex());
        }
        else if(tabs->count()==1)
        {
            this->close();
        }
    }
    else return;
}
开发者ID:oabdelaziz,项目名称:SorpSim,代码行数:61,代码来源:plotsdialog.cpp

示例4: resultReceiver

void UpdateChecker::resultReceiver(QString data)
{
    QDomDocument xml;

    qDebug() << data;

    xml.setContent(data);
    QDomElement productxml = xml.firstChildElement("product");
    if (productxml.isNull())
    {
        QMessageBox::critical(NULL, tr("Error"),
              tr("Could not check for updates. Wrong server response."));
        inProgress = false;
        return;
    }

    QDomElement urlxml = productxml.firstChildElement("url");

    QString url = urlxml.text();

    QDomNodeList versionsx = xml.elementsByTagName("version");
    if (versionsx.length()==0)
    {
        QMessageBox::critical(NULL, tr("Error"),
              tr("Could not check for updates. No versions found."));
        inProgress = false;
        return;
    }

    QString platform;

#ifdef Q_OS_WIN
    platform = "WIN";
#endif
#ifdef Q_OS_MAC
    platform = "MAC";
#endif
    if (platform.isEmpty()) platform = "UNIX";
    QStringList versions;
    QMap<QString, QUrl> urls;
    for(unsigned int i=0; i<versionsx.length(); i++)
    {
        QDomNode version = versionsx.at(i);
        QDomNode platformx = version.attributes().namedItem("platform");
        if (platformx.isNull()) continue;
        QString vpl = platformx.nodeValue();
        if ((vpl != platform) && (vpl != "ALL")) continue;
        QString ver = version.attributes().namedItem("id").nodeValue();
        versions.append(ver);
        QDomElement xurl = version.toElement().firstChildElement("url");
        urls[ver] = QUrl(xurl.text());
    }
    if (!versions.size())
    {
        if (!workSilent)
        QMessageBox::information(NULL, tr("No updates available"),
         tr("You have the latest version of this application."));
        inProgress = false;
        return;
    }
    qSort( versions.begin(), versions.end(), versionCompare); // I should write Version class with right compare
    QString version = versions.first();                       // operator and use QMap's auto sorting.
    if (versionCompare(version, QApplication::applicationVersion()))
    {
        QMessageBox msg;
        msg.addButton(tr("Yes"), QMessageBox::YesRole);
        msg.addButton(tr("No"), QMessageBox::NoRole);
        msg.setText(tr("Lastest version is %1. Do you want to update?").arg(version));
        msg.setWindowTitle(tr("Update available"));
        msg.exec();
        if (msg.buttonRole(msg.clickedButton()) == QMessageBox::YesRole)
        {
            QDesktopServices().openUrl(urls[version]);
        }
    }
    else
    {
        if (!workSilent)
        {
            QMessageBox::information(NULL, tr("No updates available"),
                       tr("You have the latest version of this application."));
        }
    }
    inProgress = false;
}
开发者ID:altamimi513,项目名称:imageshack-uploader,代码行数:85,代码来源:updatechecker.cpp

示例5: readOnlySaveDialogClicked

void mADocumentView::readOnlySaveDialogClicked(QAbstractButton *button)
{
    QMessageBox * messageBox = (QMessageBox *) sender();
    if(messageBox->buttonRole(button) == QMessageBox::AcceptRole)
        this->saveAs();
}
开发者ID:yoyonel,项目名称:ChucK_build,代码行数:6,代码来源:madocumentview.cpp


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