How to create message box with customised buttons
-
It's all described in the docs: https://doc.qt.io/qt-5/qmessagebox.html#advanced-usage
-
Below is my code snippet, but im facing seg fault at messageBox.exec(), with this error "Problem creating accessible interface for: QLabel(0x7fffe0003aa0, name = "qt_msgbox_label") " , also im not executing the below code in qt context
QMessageBox messageBox(QMessageBox::Question, tr("Critical Error"), tr("Exit the application"), QMessageBox::Yes | QMessageBox::No, NULL); messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); messageBox.setButtonText(QMessageBox::No, tr("No")); if (messageBox.exec() == QMessageBox::No) { cout << " clicked no"<< endl; }
-
Below is my code snippet, but im facing seg fault at messageBox.exec(), with this error "Problem creating accessible interface for: QLabel(0x7fffe0003aa0, name = "qt_msgbox_label") " , also im not executing the below code in qt context
QMessageBox messageBox(QMessageBox::Question, tr("Critical Error"), tr("Exit the application"), QMessageBox::Yes | QMessageBox::No, NULL); messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); messageBox.setButtonText(QMessageBox::No, tr("No")); if (messageBox.exec() == QMessageBox::No) { cout << " clicked no"<< endl; }
@Sriu1 said in How to create message box with customised buttons:
im not executing the below code in qt context
Can you elaborate on that?
Do you have a QApplication defined in your app?
-
The above code is a part of C++ class, which inherits from QObject.
I have also tried the below code snippet which you have suggested from : https://doc.qt.io/qt-5/qmessagebox.html#advanced-usage and face seg fault with the below error : "Problem creating accessible interface for: QPushButton(0x7fffe0003050)
Make sure to deploy Qt with accessibility plugins. "QMessageBox msgBox;
QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);msgBox.exec();
if (msgBox.clickedButton() == connectButton) {
// connect
} else if (msgBox.clickedButton() == abortButton) {
// abort
} -
The above code is a part of C++ class, which inherits from QObject.
I have also tried the below code snippet which you have suggested from : https://doc.qt.io/qt-5/qmessagebox.html#advanced-usage and face seg fault with the below error : "Problem creating accessible interface for: QPushButton(0x7fffe0003050)
Make sure to deploy Qt with accessibility plugins. "QMessageBox msgBox;
QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);msgBox.exec();
if (msgBox.clickedButton() == connectButton) {
// connect
} else if (msgBox.clickedButton() == abortButton) {
// abort
}@Sriu1 said in How to create message box with customised buttons:
The above code is a part of C++ class, which inherits from QObject.
OK, but do you use QApplication in your app? QObject can't work without a QApplication instance.