View Full Version : using a dialog to change settings in a main application

29th March 2006, 05:59
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!

29th March 2006, 09:00
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.

30th March 2006, 03:01
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.

31st March 2006, 18:38
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!