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
Qt 6.11 is out! See what's new in the release blog

Dialog Box return values

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++dialog boxqdialogreturn value
3 Posts 3 Posters 1.2k 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 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
        }
    ....
    
    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 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

        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
            }
        ....
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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

        • Login

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