Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to return Qmessage box output to other function
Forum Updated to NodeBB v4.3 + New Features

How to return Qmessage box output to other function

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 683 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.
  • R Offline
    R Offline
    rockon209
    wrote on last edited by
    #1

    Hello guys,
    I have a Qmessage box with yes and no button. I want to return the output of the qmessagebox whether yes button is press or no button is pressed to another function. Can anyone will help me how to do this.
    Thanks

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi and welcome

      Not sure what is question is but let's say we have

      QMessageBox msgBox;
      msgBox.setText("The document has been modified.");
      msgBox.setInformativeText("Do you want to save your changes?");
      msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
      msgBox.setDefaultButton(QMessageBox::Save);
      int ret = msgBox.exec();
      Then ret has the result.

      so if you have it in a function

      int AskTheUser() {
      QMessageBox msgBox;
      ...
      int ret = msgBox.exec();
      return ret;
      }

      then somewhere else

      void someclass::somefunc() {
      int result=AskUser();
      if (result == QMessageBox::Save)
      DOIT()
      }

      1 Reply Last reply
      3
      • R Offline
        R Offline
        rockon209
        wrote on last edited by
        #3

        ok thanks that solved my problem

        1 Reply Last reply
        1

        • Login

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