Results 1 to 5 of 5

Thread: Communication between two QDialog windows

  1. #1
    Join Date
    Sep 2009
    Location
    Kranj, Slovenia
    Posts
    25
    Thanks
    10
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Communication between two QDialog windows

    Hi;

    I am looking for a way one QDialog can communicate to another QDialog or QMainWindow. What is the best, most secure and easiest way to achieve that?
    In general I am looking one QDialog to send a string to another, and more specific I am looking how to signal a combo box to be updated when table inside a database is modified by another QDialog.

    Thank you in advance!
    Luka

  2. #2
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Communication between two QDialog windows

    The usual Qt way : Use signals and slots.

    Maybe the dialogs must not be modal or they won't update when sending the signal from dialog 1 to dialog 2.

  3. #3
    Join Date
    Sep 2009
    Location
    Kranj, Slovenia
    Posts
    25
    Thanks
    10
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Communication between two QDialog windows

    where do I put the
    Qt Code:
    1. connect(Object1, signal2, Object2, slot2)
    To copy to clipboard, switch view to plain text mode 
    code? In dialog_1 or dialog2? I put it in dialog_1, but now i do not how to connect to Object2, that is in dialog_2...

    Regards; Luka

  4. #4
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Communication between two QDialog windows

    Put the connect-code "outside" both dialogs, to where the dialogs are created.
    Qt Code:
    1. dialog_1 = new Dialog_1();
    2. dialog_2 = new Dialog_2();
    3. connect( dialog_1, SIGNAL(yourSignal(QString), dialog_2, SLOT(yourSlot(QString)) );
    4. // Show the two dialogs here
    To copy to clipboard, switch view to plain text mode 
    I'm not sure if this work, but I would try it.

  5. The following user says thank you to Boron for this useful post:

    omci (10th December 2009)

  6. #5
    Join Date
    Sep 2009
    Location
    Kranj, Slovenia
    Posts
    25
    Thanks
    10
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Talking Re: Communication between two QDialog windows

    Thanks, that worked perfectly. I can put the code connect in dialog_1 where I call dialog_2 and the connection works like a charm. And now I understand signals and slots mechanism a bit better.
    Regards, Luka

Similar Threads

  1. Windows programming in Qt (serial communication)
    By bnilsson in forum General Programming
    Replies: 17
    Last Post: 9th February 2010, 19:17
  2. Qt Jambi, deploying app on Mac & Windows fails
    By ChrisColon in forum Installation and Deployment
    Replies: 2
    Last Post: 16th February 2009, 23:05
  3. Replies: 5
    Last Post: 15th January 2009, 10:03
  4. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 02:00
  5. Qt and windows vista
    By munna in forum General Discussion
    Replies: 8
    Last Post: 11th January 2006, 23:33

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.