Results 1 to 4 of 4

Thread: using a dialog to change settings in a main application

  1. #1
    Join Date
    Feb 2006
    Posts
    7
    Qt products
    Qt3
    Platforms
    Windows

    Default using a dialog to change settings in a main application

    I have a project set up in Qt Designer 3.2 that has both a main application and a dialog box. I have several buttons in the dialog box. I am wanting to set it up where each button I click will cause a different string to be printed in a text edit in the main application. I can't seem to figure out how to make this happen.

    Is there some way that I can declare a global QString variable that I can initialize in the dialog box before displaying in the main application? Or, if not, is there some way to set it up so that one of several possible values can be sent to the main application, serving as a signal telling the main application to print a specific string?

    Any help (including code) that you could give me would be great. Thanks!

  2. #2
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: using a dialog to change settings in a main application

    Simple signals and slots are all you need. Before the application displays the dialog, have it make some connections from the dialog to the text widgets. Then when buttons are pressed have them emit signals. I'm getting sleepy over where I am, so I can't give you any code right now. It's rather simple though, it just takes some getting used to dialogs. The trick is make sure they're not modal dialogs.

  3. #3
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: using a dialog to change settings in a main application

    Another way to do this is to setup a class in your main dialog header and implementation that the secondary dialog can call to pass data back to the main dialog. In fact you can do this to pass data to the secondary dialog as well.

    Both this and the one above are fairly simple to set up and use but like you I did not find any examples on line that did this and I struggled with it until I figured it out.

  4. #4
    Join Date
    Mar 2006
    Location
    Mexico City
    Posts
    31
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: using a dialog to change settings in a main application

    Hi, filmfreak:

    I don't know if this is the best way of doing it, but it's how I have done it. When I need a child to change parameters in the main window, y send to the child, in example a dialog, a pointer to the main form. Now with that pointer, I am able to change any widget, control or variable in the main window.

    If this is what you want, I can send you an example code.

    Good luck!

Similar Threads

  1. Why when I close QDialog my main application gets killed?
    By alex chpenst in forum Qt Programming
    Replies: 2
    Last Post: 10th July 2008, 23:57
  2. Showing a dialog at application startup
    By PaladinOfKaos in forum Qt Programming
    Replies: 3
    Last Post: 1st April 2008, 21:05
  3. Deploy Qt application on Mac OS X 10.4 Tiger
    By mourad in forum Installation and Deployment
    Replies: 1
    Last Post: 30th March 2008, 17:20
  4. closing dialog in hidden main Widget
    By Lele in forum Qt Programming
    Replies: 3
    Last Post: 6th December 2006, 11:35
  5. Replies: 1
    Last Post: 15th February 2006, 23:17

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.