本文整理汇总了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;
}
示例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
{
示例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;
}
示例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;
}
示例5: readOnlySaveDialogClicked
void mADocumentView::readOnlySaveDialogClicked(QAbstractButton *button)
{
QMessageBox * messageBox = (QMessageBox *) sender();
if(messageBox->buttonRole(button) == QMessageBox::AcceptRole)
this->saveAs();
}