PDA

View Full Version : Problem with MyQDialog



fruzzo
28th April 2008, 12:07
I wrote a function, called by a pushbutton cliocked signal, like this one:



void frmMain::addElement()
myDialog dlg (this);
QString result;
if ( dlg.exec() == QDialog::Accepted ) {
result = "pippo";
}
return result;


When I press on OK pushbutton the dialog don't close itself but It's called/opened another time and when I press on OK pushbutton the second time the dialog close well.
Why?

aamer4yu
28th April 2008, 15:48
and what is the code for myDialog ??

How have u handled the slots for OK ?

jacek
29th April 2008, 00:40
Maybe the slot is called twice?

stevey
29th April 2008, 10:04
Make sure the clicked() signal of the button is connected to the accept() slot of the form.

fruzzo
30th April 2008, 13:23
Maybe the slot is called twice?

no, I've only one connect between pusbutton clicked signal and my slot addElement.

fruzzo
30th April 2008, 13:25
I've only one connect in myDialog constructor:

connect (myOkButton, SIGNAL(clicked()), frmMain, SLOT(addElement()) );

fruzzo
30th April 2008, 13:29
Make sure the clicked() signal of the button is connected to the accept() slot of the form.

Do you think that I need of :
connect ( pbOkButtonMyDialog, SIGNAL(clicked()), myDialog, SLOT(accept())); ?

aamer4yu
30th April 2008, 20:35
Do you think that I need of :
connect ( pbOkButtonMyDialog, SIGNAL(clicked()), myDialog, SLOT(accept())); ?

yesss,,,
u need to connect the clicked signal of the button to the accept slot of the myDialog.
This connection is better written in the constructor of the myDialog

stevey
1st May 2008, 23:10
Do you think that I need of :
connect ( pbOkButtonMyDialog, SIGNAL(clicked()), myDialog, SLOT(accept())); ?


Didn't I already say this?

jacek
1st May 2008, 23:14
I've only one connect in myDialog constructor:

connect (myOkButton, SIGNAL(clicked()), frmMain, SLOT(addElement()) );
Does the dialog open when you comment out this line? Maybe you invoke exec() somewhere in that dialog's code?

fruzzo
7th May 2008, 14:39
Problem solved I leave some connection from designer so by code I duplicate it!
thanx to all!;)