Results 1 to 2 of 2

Thread: Get (custom) return value of modal dialog?

  1. #1
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Get (custom) return value of modal dialog?

    Hi
    i have a problem with interaction between a QDialog and a QMainWindow.

    On startup my program shows a QMainWindow (ControlPanel). On this Controlpanel there are serveral menubuttons. One of them opens a QDialog (NewIncident). In NewIncident the user can type some information about an incident (i write a program for our local firedepartment by the way^^). If the user clicks the alerting button, NewIncident creates an instance of an Incident object which contains every information typed in by the user(e.g. Location, Caller, Phonenumber etc.). My problem is how do i return the instance to Controlpanel? ControlPanel needs this instance to work with it (list of current incident, history of incidents,...).

    Here is some code:

    Qt Code:
    1. void ControlPanel::on_btNewIncident_clicked()
    2. {
    3. NewIncident *newincident = new NewIncident(this);
    4. newincident->exec();
    5. Incident incSheet = newincident->getIncSheet();
    6. qDebug() << incSheet.acceptor;
    7. }
    To copy to clipboard, switch view to plain text mode 
    I only used a qDebug() to see if anything is available in incSheet. But it outputs ""

    I dont know how to go further -.- I talked to a friend who programs a lot (unfortunately not with Qt) but he could not help me out.
    How can i get this to work?

    Greetz

    p.s.: would be nice if newincident could stay a modal dialog. I dont want that the user can interact with other windows of the program while NewIncident is there.

  2. #2
    Join Date
    Jan 2012
    Posts
    23
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get (custom) return value of modal dialog?

    Ok i solved this problem on my own.
    I just changed some things:

    Qt Code:
    1. NewIncident *newincident = new NewIncident(this);
    2. if(!newincident->exec()){
    3. incSheet = newincident->getIncSheet();
    4. refresh(incSheet);
    5. }
    To copy to clipboard, switch view to plain text mode 

    I realised that exec() returns 0 in my program so i have to catch !newincident->exec() of course -.-'
    Then i initialized a class member variable(incSheet) of type Incident with the return value of getIncSheet() <- returns all values i need
    refresh() is only a function to refresh some element on ControlPanel.

Similar Threads

  1. modal dialog in mouseReleaseEvent
    By cresta in forum Qt Programming
    Replies: 0
    Last Post: 14th October 2011, 03:18
  2. Non-Modal about dialog?
    By N3wb in forum Qt Programming
    Replies: 1
    Last Post: 8th December 2010, 05:47
  3. QT Modal Dialog
    By jiapei100 in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2010, 17:15
  4. Special Modal Dialog
    By adonel in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2008, 08:12
  5. System modal dialog!!
    By boss_bhat in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2006, 07:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.