Уведомления
Очистить все
Всем привет, набросайте пожалуйста кто-нибудь простейший пример диалогового окна на базе QMessageBox или QDialog - без разницы - для стандартной формы. Нужно вывести пользователю предупреждение и спросить подтверждение (две кнопки - принять/отказаться). После закрытия окна проанализировать, что выбрал пользователь.
Плохо ориентируюсь в официальной документации, если у кого будет возможность, набросайте пожалуйста простенький вариант, дальше буду уже копаться сам.
Создатель темы Размещено : 31.10.2024 20:30
Привет, лови:
QMessageBox msgBox;
msgBox.setText("Some text");
msgBox.setInformativeText("Settings changed."
"Discard changes?");
msgBox.setStandardButtons(QMessageBox::Apply | QMessageBox::Discard);
int result = msgBox.exec();
switch(result)
{
case QMessageBox::Discard:
// User clicked "Discard"
break;
case QMessageBox::Apply:
// User clicked "Apply"
break;
default:
break;
}
Размещено : 01.11.2024 11:40
Создатель темы Размещено : 01.11.2024 13:37
QMessageBox::Ok 0x00000400 An "OK" button defined with the AcceptRole. QMessageBox::Open 0x00002000 An "Open" button defined with the AcceptRole. QMessageBox::Save 0x00000800 A "Save" button defined with the AcceptRole. QMessageBox::Cancel 0x00400000 A "Cancel" button defined with the RejectRole. QMessageBox::Close 0x00200000 A "Close" button defined with the RejectRole. QMessageBox::Discard 0x00800000 A "Discard" or "Don't Save" button, depending on the platform, defined with the DestructiveRole. QMessageBox::Apply 0x02000000 An "Apply" button defined with the ApplyRole. QMessageBox::Reset 0x04000000 A "Reset" button defined with the ResetRole. QMessageBox::RestoreDefaults 0x08000000 A "Restore Defaults" button defined with the ResetRole. QMessageBox::Help 0x01000000 A "Help" button defined with the HelpRole. QMessageBox::SaveAll 0x00001000 A "Save All" button defined with the AcceptRole. QMessageBox::Yes 0x00004000 A "Yes" button defined with the YesRole. QMessageBox::YesToAll 0x00008000 A "Yes to All" button defined with the YesRole. QMessageBox::No 0x00010000 A "No" button defined with the NoRole. QMessageBox::NoToAll 0x00020000 A "No to All" button defined with the NoRole. QMessageBox::Abort 0x00040000 An "Abort" button defined with the RejectRole. QMessageBox::Retry 0x00080000 A "Retry" button defined with the AcceptRole. QMessageBox::Ignore 0x00100000 An "Ignore" button defined with the AcceptRole. QMessageBox::NoButton 0x00000000 An invalid button.
Здесь все есть - ссылка.
Размещено : 01.11.2024 13:56
Спасибо!
Создатель темы Размещено : 01.11.2024 15:22