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. Dialog Box return values
Forum Updated to NodeBB v4.3 + New Features

Dialog Box return values

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++dialog boxqdialogreturn value
3 Posts 3 Posters 609 Views
  • 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.
  • B Offline
    B Offline
    BigBen
    wrote on 3 Jun 2022, 04:23 last edited by
    #1

    How can I make a dialog box return different values (0, 1, 2, 3), on the click of the same button depending on different conditions.
    For example:

    on_startButton_clicked(){
        if(condition 1){
            dialog returns 0
        }
        else if(condition 2){
            dialog returns 1 
        }
        else if(condition 3){
            dialog returns 2
        }
    ....
    
    J 1 Reply Last reply 3 Jun 2022, 06:36
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 3 Jun 2022, 04:47 last edited by
      #2

      You can't - add a custom functio to your class which returns your value so you can use it later on.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • B BigBen
        3 Jun 2022, 04:23

        How can I make a dialog box return different values (0, 1, 2, 3), on the click of the same button depending on different conditions.
        For example:

        on_startButton_clicked(){
            if(condition 1){
                dialog returns 0
            }
            else if(condition 2){
                dialog returns 1 
            }
            else if(condition 3){
                dialog returns 2
            }
        ....
        
        J Online
        J Online
        JonB
        wrote on 3 Jun 2022, 06:36 last edited by
        #3

        @BigBen
        Assuming you are wanting to return those values as soon as the startButton is clicked, you can just call void QDialog::done(int r) with the desired value. Or do that later with the value if you want it returned later.

        1 Reply Last reply
        1

        1/3

        3 Jun 2022, 04:23

        • Login

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