本文整理汇总了C++中QMessageBox::clickedButton方法的典型用法代码示例。如果您正苦于以下问题:C++ QMessageBox::clickedButton方法的具体用法?C++ QMessageBox::clickedButton怎么用?C++ QMessageBox::clickedButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMessageBox
的用法示例。
在下文中一共展示了QMessageBox::clickedButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onFindRepoAction
void Gitarre::onFindRepoAction()
{
int i = RepoView->currentIndex().row();
QTreeWidgetItem *item = RepoView->topLevelItem(i);
QString itemName = item->text(0);
QString dirPath = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
"/home",
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if (!dirPath.isEmpty())
{
QDir dir (dirPath);
if (dir.dirName() == itemName)
{
if (FindRepoIndex (dirPath) != -1)
{
QMessageBox::information(this, "Find repository", "This repository already exists in the list");
onFindRepoAction();
}
else
ReplaceRepo (dirPath, i);
}
else
{
QMessageBox messageBox (QMessageBox::NoIcon, "Find repository", "The name of this repository does not match");
QPushButton *buttonReplace = messageBox.addButton ("Replace", QMessageBox::AcceptRole);
QPushButton *buttonBrowse = messageBox.addButton ("Browse...", QMessageBox::RejectRole);
messageBox.addButton (QMessageBox::Cancel);
if (messageBox.clickedButton() == buttonReplace)
ReplaceRepo (dirPath, i);
else if (messageBox.clickedButton() == buttonBrowse)
onFindRepoAction();
}
}
}
示例2: nextMove
void GameWidget::nextMove()
{
_gameController->nextMove();
bool gameFinished = _gameController->gameOver();
this->updateActor();
_lblMovementGhostCounter->setText(QString::number(_gameController->getGhostMovementCounter()));
if(gameFinished)
{
QMessageBox msgBox;
msgBox.setText("Le Pacman a été attrapé !");
QString text = "Les ghosts ont mis ";
text += QString("%1").arg( _gameController->getGhostMovementCounter() );
text += " coups pour attraper le Pacman.\n";
msgBox.setDetailedText(text);
QPushButton *btnRestart = msgBox.addButton(tr("&Recommener"), QMessageBox::AcceptRole);
QPushButton *btnMenu = msgBox.addButton(tr("Revenir au &menu"), QMessageBox::RejectRole);
msgBox.exec();
if (msgBox.clickedButton() == btnRestart)
{
emit restarted();
}
else if (msgBox.clickedButton() == btnMenu)
{
emit terminated();
}
}
}
示例3: on_win
void TicTacToe::on_win(int k)
{
QMessageBox message;
message.setWindowTitle("garble!");
if (k)
{
if (k > 0)
message.setText("Cross guy won");
else
message.setText("Circle guy won");
}
if (!k)
message.setText("A tie!");
message.setInformativeText("Would you like to start a new game?");
QPushButton* newGame = message.addButton("New Game", QMessageBox::ActionRole);
QPushButton* end = message.addButton("Close", QMessageBox::ActionRole);
message.exec();
if (message.clickedButton() == newGame)
emit(reboot());
else if (message.clickedButton() == end)
close();
}
示例4: maybeSave
//maybeSave()
bool MdiChild::maybeSave()
{
//如果文档被更改过
if(document()->isModified())
{
QMessageBox box;
box.setWindowTitle("多文档编辑器");
box.setText(tr("是否保存对%1的更改?").arg(userFriendlyCurrentFile()));
box.setIcon(QMessageBox::Warning);
//添加按钮,QMessgaeBox::YesRole可以表明这个按钮的行为
QPushButton *yesBtn=box.addButton("是(&Y)",QMessageBox::YesRole);
box.addButton("否(&N)",QMessageBox::NoRole);
QPushButton *cancelBtn=box.addButton("取消",QMessageBox::RejectRole);
box.exec();//弹出对话框,让用户选择是否保存修改,或者取消关闭操作
//如果用户选择是,则返回保存操作的结果;如果选择取消,则返回false
if(box.clickedButton()==yesBtn)
{
return save();
}
else if(box.clickedButton()==cancelBtn)
{
return false;
}
return true;//如果文档未被修改,则直接返回true
}
}
示例5: removeAct
void ResourceDock::removeAct() {
auto item = resTree->currentItem();
if (item->parent() != nullptr) {
auto found = resMap.find(item->text(0));
QMessageBox::StandardButton reply;
QMessageBox msgBox;
msgBox.setText("Choose Remove to remove \'" + item->text(0) + "\' from project.\n"
"Choose Delete to permanently delete \'" + item->text(0) + "\' from project.");
QAbstractButton *btnRemove = msgBox.addButton("Remove", QMessageBox::YesRole);
QAbstractButton *btnDelete = msgBox.addButton("Delete", QMessageBox::DestructiveRole);
QAbstractButton *btnCancel = msgBox.addButton("Cancel", QMessageBox::NoRole);
msgBox.setIcon(QMessageBox::Question);
msgBox.exec();
if (msgBox.clickedButton() == btnCancel) {
return;
} else if (msgBox.clickedButton() == btnRemove) {
emit(resDeleted(found.key(), found->second));
} else if (msgBox.clickedButton() == btnDelete) {
emit(resDeleted(found.key(), found->second));
QFile file(resDir + item->text(0));
file.remove();
}
delete item;
resMap.erase(found);
}
}
示例6: GenderCheck
//###################################################################################################
// new gender check for 0.4
bool SettingsManager::GenderCheck(){
using namespace std;
QMessageBox m;
m.setText("Please select your gender:");
m.setWindowTitle("RoboJournal");
m.setIcon(QMessageBox::Question);
QPushButton *male=m.addButton("Male",QMessageBox::AcceptRole);
QPushButton *female=m.addButton("Female",QMessageBox::AcceptRole);
m.setStandardButtons(NULL);
m.exec();
bool isMale;
if(m.clickedButton() == male){
//cout << "User chose male" << endl;
isMale=true;
}
if(m.clickedButton() == female){
//cout << "User chose female" << endl;
isMale=false;
}
return isMale;
}
示例7: saveChanges
bool MainWindow::saveChanges()
{
if(!m_modified)
{
return true;
}
else
{
QMessageBox closeMessageBox;
closeMessageBox.setText("You have unsaved changes.");
closeMessageBox.setInformativeText("Do you want to save your changes?");
QPushButton *saveButton = closeMessageBox.addButton("Save", QMessageBox::ActionRole);
QPushButton *discardButton = closeMessageBox.addButton("Discard", QMessageBox::ActionRole);
closeMessageBox.addButton("Cancel", QMessageBox::RejectRole);
closeMessageBox.exec();
if( closeMessageBox.clickedButton() == saveButton )
{
saveFile();
return true;
}
else if( closeMessageBox.clickedButton() == discardButton )
{
return true;
}
else
{
return false;
}
}
}
示例8: createUser
void UserManagement::createUser(QString name)
{
//CREATES A USER
QString time=QString::number(QDateTime::currentDateTime().toTime_t());//GETS A CURRENT TIMESTAMP
userTimestamp.append(time);
if(nameValidation(name))
{
//CUSTOM MESSAGE BOX TO CONFIRM USER CREATION
QMessageBox invalidName;
invalidName.setText("Are you sure you want to create this user?");
QAbstractButton *okayButton =invalidName.addButton(QObject::tr("OKAY"),QMessageBox::ActionRole);
QAbstractButton *cancelButton =invalidName.addButton(QObject::tr("CANCEL"),QMessageBox::ActionRole);
invalidName.exec();
if(invalidName.clickedButton() == okayButton)
{
userPlayer.append(name);
userLevel.append("1");
}
if(invalidName.clickedButton()==cancelButton)
{
userPlayer.append("");
userLevel.append("");
}
}
else
{
userPlayer.append("");
userLevel.append("");
}
userSort();
}
示例9: sonucKapat
void proje::sonucKapat()
{
if(formEkleSonuc.ekleSonucDegisiklikVar==true)
{
if(formEkleSonuc.ekleSonucDegisiklikVar==true)
{
QMessageBox msgBox;
msgBox.setText("Değişiklikler kaydedilsin mi?");
msgBox.setIcon(QMessageBox::Warning);
QPushButton *tamam = msgBox.addButton("Tamam", QMessageBox::ActionRole);
QPushButton *iptal = msgBox.addButton("İptal", QMessageBox::ActionRole);
msgBox.exec();
if (msgBox.clickedButton() == tamam)
{
tamamSonuc();
}
else if (msgBox.clickedButton() == iptal)
{
formEkleSonuc.ekleSonucDegisiklikVar=false;
formEkleSonuc.degisenIDOgrenci.clear();
msgBox.close();
}
}
}
formEkleSonuc.close();
}
示例10: on_nouveau_clicked
void FenEdition::on_nouveau_clicked()
{
QMessageBox confirmationNouveau;
confirmationNouveau.setText(tr("Voulez-vous enregistrer ?"));
confirmationNouveau.setWindowTitle("DrumMastery");
QAbstractButton* boutonOui = confirmationNouveau.addButton(tr("Oui"), QMessageBox::YesRole);
QAbstractButton* boutonNon = confirmationNouveau.addButton(tr("Non"), QMessageBox::NoRole);
confirmationNouveau.addButton(tr("Annuler"), QMessageBox::RejectRole);
confirmationNouveau.exec();
if (confirmationNouveau.clickedButton()==boutonOui)
{
FenEdition *nouvelleFenetre;
nouvelleFenetre = new FenEdition;
nouvelleFenetre->show();
}
if (confirmationNouveau.clickedButton()==boutonNon)
{
FenEdition *nouvelleFenetre;
nouvelleFenetre = new FenEdition;
nouvelleFenetre->show();
}
}
示例11: sSave
bool xTupleDesignerActions::sSave()
{
QMessageBox save;
save.setText("How do you want to save your changes?");
QPushButton *cancel= save.addButton(QMessageBox::Cancel);
QPushButton *db = save.addButton(tr("Database only"), QMessageBox::AcceptRole);
QPushButton *file = save.addButton(tr("File only"), QMessageBox::AcceptRole);
QPushButton *both = save.addButton(tr("Database and File"),QMessageBox::AcceptRole);
save.setDefaultButton(_designer->formwindow()->fileName().isEmpty() ? db : both);
save.setEscapeButton((QAbstractButton*)cancel);
save.exec();
if (save.clickedButton() == (QAbstractButton*)db)
return sSaveToDB();
else if (save.clickedButton() == (QAbstractButton*)file)
return sSaveFile();
else if (save.clickedButton() == (QAbstractButton*)both)
return sSaveFile() && sSaveToDB();
else if (save.clickedButton() == (QAbstractButton*)cancel)
return false;
else
{
qWarning("xTupleDesignerActions::sSave() bug - unknown button clicked");
return false;
}
}
示例12: keyPressEvent
void KviInput::keyPressEvent(QKeyEvent * e)
{
if(e->modifiers() & Qt::ControlModifier)
{
switch(e->key())
{
case Qt::Key_Enter:
case Qt::Key_Return:
{
if(m_pMultiLineEditor)
{
QString szText;
m_pMultiLineEditor->getText(szText);
if(szText.isEmpty())
return;
if(KVI_OPTION_BOOL(KviOption_boolWarnAboutPastingMultipleLines))
{
if(szText.length() > 256)
{
if(szText[0] != '/')
{
int nLines = szText.count('\n') + 1;
if(nLines > 15)
{
QMessageBox pMsgBox;
pMsgBox.setText(__tr2qs("You're about to send a message with %1 lines of text.<br><br>"
"This warning is here to prevent you from accidentally "
"pasting and sending a really large, potentially unedited message from your clipboard.<br><br>"
"Some IRC servers may also consider %1 lines of text a flood, "
"in which case you will be disconnected from said server.<br><br>"
"Do you still want the message to be sent?").arg(nLines));
pMsgBox.setWindowTitle(__tr2qs("Confirm Sending a Large Message - KVIrc"));
pMsgBox.setIcon(QMessageBox::Question);
QAbstractButton * pAlwaysButton = pMsgBox.addButton(__tr2qs("Always"), QMessageBox::YesRole);
/* QAbstractButton *pYesButton = */ pMsgBox.addButton(__tr2qs("Yes"), QMessageBox::YesRole);
QAbstractButton * pNoButton = pMsgBox.addButton(__tr2qs("No"), QMessageBox::NoRole);
pMsgBox.setDefaultButton(qobject_cast<QPushButton *>(pNoButton));
pMsgBox.exec();
if(pMsgBox.clickedButton() == pAlwaysButton)
{
KVI_OPTION_BOOL(KviOption_boolWarnAboutPastingMultipleLines) = false;
}
else if(pMsgBox.clickedButton() == pNoButton || pMsgBox.clickedButton() == nullptr)
{
return;
}
}
}
}
}
szText.replace('\t', QString(KVI_OPTION_UINT(KviOption_uintSpacesToExpandTabulationInput), ' ')); //expand tabs to spaces
KviUserInput::parse(szText, m_pWindow, QString(), m_pCommandlineModeButton->isChecked());
m_pMultiLineEditor->setText("");
}
}
break;
}
}
}
示例13: determinWorkflow
Workflow WorkflowManager::determinWorkflow( App::Document *doc) {
Workflow rv = getWorkflowForDocument (doc);
if (rv != Workflow::Undetermined) {
// Return if workflow is known
return rv;
}
// Guess the workflow again
rv = guessWorkflow (doc);
if (rv != Workflow::Modern) {
QMessageBox msgBox;
if ( rv == Workflow::Legacy ) { // legacy messages
msgBox.setText( QObject::tr( "The document \"%1\" you are editing was design with old version of "
"PartDesign workbench." ).arg( QString::fromStdString ( doc->getName()) ) );
msgBox.setInformativeText (
QObject::tr( "Do you want to migrate in order to use modern PartDesign features?" ) );
} else { // The document is already in the middle of migration
msgBox.setText( QObject::tr( "The document \"%1\" seems to be either in the middle of"
" the migration process from legacy PartDesign or have a slightly broken structure."
).arg( QString::fromStdString ( doc->getName()) ) );
msgBox.setInformativeText (
QObject::tr( "Do you want to make the migration automatically?" ) );
}
msgBox.setDetailedText( QObject::tr( "Note If you choose to migrate you won't be able to edit"
" the file wtih old FreeCAD versions.\n"
"If you refuse to migrate you won't be able to use new PartDesign features"
" like Bodies and Parts. As a result you also won't be able to use your parts"
" in the assembly workbench.\n"
"Although you will be able to migrate any moment later with 'Part Design->Migrate...'." ) );
msgBox.setIcon( QMessageBox::Question );
QPushButton * yesBtn = msgBox.addButton ( QMessageBox::Yes );
QPushButton * manuallyBtn = msgBox.addButton (
QObject::tr ( "Migrate manually" ), QMessageBox::YesRole );
// If it is already a document in the middle of the migration the user shouldn't refuse to migrate
if ( rv != Workflow::Undetermined ) {
msgBox.addButton ( QMessageBox::No );
}
msgBox.setDefaultButton ( yesBtn );
// TODO Add some description of manual migration mode (2015-08-09, Fat-Zer)
msgBox.exec();
if ( msgBox.clickedButton() == yesBtn ) {
Gui::Application::Instance->commandManager().runCommandByName("PartDesign_Migrate");
rv = Workflow::Modern;
} else if ( msgBox.clickedButton() == manuallyBtn ) {
rv = Workflow::Modern;
} else {
rv = Workflow::Legacy;
}
}
// Actually set the result in our map
dwMap[ doc ] = rv;
return rv;
}
示例14: agentStartPause
void ManagerWindow::agentStartPause()
{
bool allAccounts;
if (this->ui->accountsTabWidget->count() > 1) {
QMessageBox msgBox;
msgBox.setText(tr("You have more than one account."));
msgBox.setInformativeText(tr("Do you want to start/pause all accounts "
"or only the current account?"));
QAbstractButton* allBtn = msgBox.addButton(tr("All accounts"), QMessageBox::YesRole);
QAbstractButton* currentBtn =
msgBox.addButton(tr("Current account only"), QMessageBox::NoRole);
msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
msgBox.setIcon(QMessageBox::Question);
msgBox.exec();
if (msgBox.clickedButton() == allBtn)
allAccounts = true;
else if (msgBox.clickedButton() == currentBtn)
allAccounts = false;
else
return;
}
//Disable all buttons
this->ui->startPauseButton->setEnabled(false);
for (QHash<QToolButton*, QString>::const_iterator i = this->queueButtons.constBegin();
i != this->queueButtons.constEnd();
i++) {
QToolButton* const queueButton = i.key();
queueButton->setEnabled(false);
}
bool paused = this->ui->accountsTabWidget->currentWidget()->property("Paused").toBool();
const int listSize = this->config->extensions.size();
for (int i = 0; i < listSize; i++) {
if (allAccounts || i == this->ui->accountsTabWidget->currentIndex()) {
//Send start/pause request for all queues this account belongs to
AstCtiExtensionPtr extension = this->config->extensions.at(i);
if (paused == this->ui->accountsTabWidget->widget(i)->property("Paused").toBool()) {
for (AstCtiAgentStatusHash::const_iterator i = extension->queues.constBegin();
i != extension->queues.constEnd();
i++) {
const QString queue = i.key();
if (paused)
if (i.value() == AgentStatusPaused)
emit this->pauseRequest(queue, extension->channelName);
else
emit this->startRequest(queue, extension->channelName);
else
if (i.value() == AgentStatusLoggedIn)
emit this->pauseRequest(queue, extension->channelName);
}
}
}
}
}
示例15: changeFileName
/**
* @brief RsCollectionDialog::changeFileName: Change the name of saved file
*/
void RsCollectionDialog::changeFileName()
{
QString fileName;
if(!misc::getSaveFileName(this, RshareSettings::LASTDIR_EXTRAFILE
, QApplication::translate("RsCollectionFile", "Create collection file")
, QApplication::translate("RsCollectionFile", "Collection files") + " (*." + RsCollectionFile::ExtensionString + ")"
, fileName,0, QFileDialog::DontConfirmOverwrite))
return;
if (!fileName.endsWith("." + RsCollectionFile::ExtensionString))
fileName += "." + RsCollectionFile::ExtensionString ;
std::cerr << "Got file name: " << fileName.toStdString() << std::endl;
QFile file(fileName) ;
if(file.exists())
{
RsCollectionFile collFile;
if (!collFile.checkFile(fileName,true)) return;
QMessageBox mb;
mb.setText(tr("Save Collection File."));
mb.setInformativeText(tr("File already exists.")+"\n"+tr("What do you want to do?"));
QAbstractButton *btnOwerWrite = mb.addButton(tr("Overwrite"), QMessageBox::YesRole);
QAbstractButton *btnMerge = mb.addButton(tr("Merge"), QMessageBox::NoRole);
QAbstractButton *btnCancel = mb.addButton(tr("Cancel"), QMessageBox::ResetRole);
mb.setIcon(QMessageBox::Question);
mb.exec();
if (mb.clickedButton()==btnOwerWrite) {
//Nothing to do
} else if (mb.clickedButton()==btnMerge) {
//Open old file to merge it with RsCollection
QDomDocument qddOldFile("RsCollection");
if (qddOldFile.setContent(&file)) {
QDomElement docOldElem = qddOldFile.elementsByTagName("RsCollection").at(0).toElement();
collFile.recursCollectColFileInfos(docOldElem,_newColFileInfos,QString(),false);
}//(qddOldFile.setContent(&file))
} else if (mb.clickedButton()==btnCancel) {
return;
} else {
return;
}
} else {//if(file.exists())
//create a new empty file to check if name if good.
if (!file.open(QFile::WriteOnly)) return;
file.remove();
}//if(file.exists())
_fileName = fileName;
updateList();
}