Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to create message box with customised buttons
Forum Updated to NodeBB v4.3 + New Features

How to create message box with customised buttons

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 2 Posters 4.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sriu1
    wrote on last edited by
    #1

    how to create message box with customized buttons , which also takes input from user and performs some action.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      It's all described in the docs: https://doc.qt.io/qt-5/qmessagebox.html#advanced-usage

      (Z(:^

      1 Reply Last reply
      1
      • S Offline
        S Offline
        Sriu1
        wrote on last edited by
        #3

        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;
        }
        
        sierdzioS 1 Reply Last reply
        0
        • S Sriu1

          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;
          }
          
          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @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?

          (Z(:^

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sriu1
            wrote on last edited by
            #5

            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
            }

            sierdzioS 1 Reply Last reply
            0
            • S Sriu1

              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
              }

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              @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.

              (Z(:^

              1 Reply Last reply
              1
              • S Offline
                S Offline
                Sriu1
                wrote on last edited by
                #7

                Thanks for the input. I will try accordingly and get back.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved