Thread: QT Main and Dialog

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    307

    QT Main and Dialog

    have a dialog

    and on

    Code:
    voidCardSelect::on_pushButton_clicked()
    
       {
          //send a INT back to main//   
       }
    and in main i have

    Code:
    CardSelectQDialog;
    QDialog.setModal(true);
    if(QDialog.exec())
         {
             Card=//the return INT from Dialog//
             QMessageBox::information(0,"Success",QString::number(Card));
          }
    i am missing something to connect the variable from the dialog, and use it in the main and close the dialog....

  2. #2
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    428
    What about passing a reference to the function?
    Virtual reality hello world http://www.rodneybrothers.com/vr/vrh...rld/index.html in html and javascript.
    Viewable with dodocase, google cardboard, OR, and other compatible VR gear.

  3. #3
    Registered User
    Join Date
    Dec 2012
    Posts
    307
    it isnt a function, it is a dialog, seperate header, seperate cpp, seperate UI.

    just need to send the value back to main. and have no idea how to do it. This is also my first time ever using multiple files for a program, normally i just use a single cpp for a program. multiple sources, gui, and qt all newish for me

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    I'm not sure if that is the Qt way of doing this, but you could create a private field called "int DialogResult" and a method "int GetDialogResult() const" that will return that field in your CardSelect class. Write the int to your private field and later call the method on your dialog to get the int.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User
    Join Date
    Dec 2012
    Posts
    307
    ok that sounds good, just no idea HOW to do that!

  6. #6
    Registered User
    Join Date
    Dec 2012
    Posts
    307
    got this to work....

    in main.cpp
    Code:
    CardSelectQDialog;
    QDialog.setModal(true);
    Card=(QDialog.exec());
    


    and in my dialog

    Code:
    voidCardSelect::on_pushButton_clicked()
    {
        done(card);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Connecting Dialog window to main window
    By vopo in forum Windows Programming
    Replies: 1
    Last Post: 11-26-2007, 07:55 PM
  2. modeless dialog not interacting with main window
    By scwizzo in forum Windows Programming
    Replies: 3
    Last Post: 08-30-2007, 04:33 PM
  3. Editing the main dialog when starting from a VS MFC project?
    By Sfpiano in forum Windows Programming
    Replies: 3
    Last Post: 08-07-2005, 10:36 PM
  4. How to Use a Dialog as Main Window?
    By Mike2432 in forum Windows Programming
    Replies: 8
    Last Post: 07-26-2002, 06:20 PM
  5. I want main window to be a dialog...
    By Garfield in forum Windows Programming
    Replies: 15
    Last Post: 02-20-2002, 08:41 PM