Results 1 to 3 of 3

Thread: How to return a lot of data from a QDialog

  1. #1
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to return a lot of data from a QDialog

    I'm writing a dialog and when the user is clicking ok in the dialog, the dialog should send all the data that has been entered back to the mainwindow. As I see it I have two options.
    When creating the dialog, send a pointer to the mainwindow and call a function parent->doStuff(...config data...);

    or do this with signals and slots, but that seems a little overkill, calling connect and disconnect(?) to release the signals/slots.

    Are there more options for doing this?
    Any way that is considered to be the "best"?

  2. #2
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to return a lot of data from a QDialog

    Hi,

    Ideas are quite good, but I would not send mainwindow's pointer to it's child, why? It is too dangerous. I would thing about additional methods, depending on the amount of data you need to "configure":
    1) create a custom data structure which will store the configuration data in the dialog and the dialog, before being destroyed, can return the data to the mainwindow.
    2) you can have the configuration data in the mainWindow and send it as a pointer to the dialog; the dialog would then override the data and after comming back to mainwindow you would have the data you need.
    3) if you need to react to whenever the data is changed in the mainwindow and cannot wait till the dialog will be closed you can do the same + adding a signal to notify the mainWindow that the data has changed.
    I suppose there may be some other solutions;
    You should concentrate that the code will be easy to modify and be safe.

    Kacper
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  3. The following 3 users say thank you to maverick_pol for this useful post:

    gustavosbarreto (20th October 2008), Morea (20th October 2008), waynew (9th January 2010)

  4. #3
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to return a lot of data from a QDialog

    Your suggestions 2 and 3 sounds best.

Similar Threads

  1. QSql*Model + QTreeView : make a tree
    By punkypogo in forum Qt Programming
    Replies: 18
    Last Post: 24th October 2008, 19:14
  2. Custom Model Advice Requested
    By mclark in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 17:26
  3. Once more : QAbstractItemModel woes
    By Valheru in forum Qt Programming
    Replies: 10
    Last Post: 15th January 2008, 11:44
  4. QTableView Repaint/Refresh
    By millsks in forum Newbie
    Replies: 9
    Last Post: 10th January 2008, 18:18
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

Tags for this Thread

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.