PDA

View Full Version : Dialog opens twice



ulmly
29th June 2009, 13:42
Hi !

If user clicked a button then a dialog will pop up.

The problem is that the dialog pops up twice, one after another. That means, after user give an input and click OK, the same dialog appears and asks user again.

However, other buttons which do open the same dialog have no such a problem.

The dialog class inherits QDialog.

Does converting to Qt4 play role in this case ? Because the problem button is already located on ui file which has been converted through Qt4's designer and the other buttons are still on Qt3's ui files.

Thx in advance.

wagmare
29th June 2009, 13:45
show us the code snippet : how u are poping the new dialog ..

ulmly
29th June 2009, 13:53
On the problem button (defined in cpp file):



void
SensitivitiesWidget::on_SingleFunctionChooser_clic ked()
{
const CCopasiObject * pObject =
CCopasiSelectionDialog::getObjectSingle(this,
CCopasiSimpleSelectionTree::NumericValues);
}


On one of other buttons (defined in ui.h file):



void Curve2DWidget::buttonPressedX()
{
if (!mpModel) return;

mpObjectX = CCopasiSelectionDialog::getObjectSingle(this,
CCopasiSimpleSelectionTree::NumericValues);
}

ulmly
29th June 2009, 14:27
If I go back to the old Qt3's ui file, the problem does not come up.

I believe this is about converting problem to Qt4.

However, I did do some works on interface only in converting progress :crying:

ulmly
30th June 2009, 13:20
No, the problem does not really correlated to converting process.

If I changed the name of button, the problem will disappear. The window will pop up once.

However, I don't still understand why changing the button name simply solve the problem. I have checked whether the name is used somewhere else in the code, but everything looks like OK.

Any idea ??? :confused:

wysota
30th June 2009, 13:58
Do you have a connect() statement related to the on_SingleFunctionChooser_clicked() slot?

ulmly
30th June 2009, 14:10
Yes, I have.

The connect() statement is automatically generated from SensitivitiesWidget.ui file. That means it is in ui_SensitivitiesWidget.h.

The slot itself has been declared in SensitivitiesWidget.h and defined in SensitivitiesWidget.cpp.

wysota
30th June 2009, 14:55
Then you have two connections to the same slot. If you name a slot in a form of on_objectName_signalSignature() it will be automatically connected to the signalSignature() signal from objectName. Either remove the connection in Designer or change the slot name.

ulmly
30th June 2009, 19:10
Aha ! I see !

The on_objectName_signalSignature() slot is automatically connected to the signalSignature() signal from objectName. This is done by default. Also, I should not spend an extra effort to make signal-slot connection, even in Qt Designer. Just declare it in header file and define in implementation one.

However, why am I not able to see the 'second' connect() statement ? Is the statement hidden from us ?

wysota
30th June 2009, 20:25
The on_objectName_signalSignature() slot is automatically connected to the signalSignature() signal from objectName. This is done by default. Also, I should not spend an extra effort to make signal-slot connection, even in Qt Designer. Just declare it in header file and define in implementation one.
It's better to make the connection graphically and name the slot in a way that it gives more information about what it does instead of a vague information when it is triggered.


However, why am I not able to see the 'second' connect() statement ? Is the statement hidden from us ?
The second connection is done by
QMetaObject::connectSlotsByName() that is called from setupUi() in the file generated by uic from your Designer form.