[Qt-creator] Passing a value back from a form

Robert Wood robert.wood at apostrophe.co.uk
Tue Mar 22 20:44:23 CET 2011


I am trying to create a pop-up window that has a load of JPEGs on it. 
When one of the JEPGs (which is put on a push button) is clicked, I want 
the form to close and a value dependent on which button is pressed 
passed back to the calling form.

I have tried a few things such as making it a dialogue box, but this 
doesn't work as you seem to need to press the OK button. I tried this 
(using a naughty global variable!):


// This routine does return the value and close te form
quint16 config_dialogue::returnConfig(void)
{

	return RetVal;

}

// This is one of the JPEG buttons; it does set the RetVal to 42
// but it does not shut the form down and pass the value back
quint16 config_dialogue::nineGroups(void)
{

	RetVal = 42;
	returnConfig();

}

And although I do get 42 back. I still have to press the OK button.

So, is there a way to have a load of buttons on a form and whichever 
button you press it passes a unique number back to the calling form 
please? It doesn't have to be a dialogue, just a normal form will be fine.

Thanks!



More information about the Qt-creator-old mailing list