QDialog show method's wierd problem on signal slot mechanism.
Hi All,
I have derived MyDialog class from QDialog. In MyDialog class's constructor I have connected some widget's signal and slots after setup ui. That's all for now. I use MyDıalog class from my application by;
MyDialog *md = new MyDialog(this);
md->show();
When I call show method at first time my connected slot's running one by one although there isn't any signal emitted under my control which are related each connected slot. But after first show method calling this situation disappered. I mean I hide window and show again and this situation doesn't exist.
But if I show and hide method before the signal slot connection in my constructor method there is no automatic slot running in my other show method calling.
Why my slots running automaticaly after my first show method calling? Do you have any idea?
Thanks in advance.
Re: QDialog show method's wierd problem on signal slot mechanism.
Please post all your code, so that we don't have to guess blindfolded.
Joh
Re: QDialog show method's wierd problem on signal slot mechanism.
Hi!
Please use the forums-code-tags! In the advanced edit there is a "#"-button!
I think that one of your slots is called on first show, because the value has changed between initialization and then.
Your code is not compilable as is.. so you will have to track down the source of the problem yourself. Remove the Show Hide Workaround. remove all connects - comment them out. And uncomment them one by one.
Maybe it has to do with values you set in Designer? A plain QDoubleSpinboxes ValueChanged doesn't fire on creation..
Code:
#include <QApplication>
#include <QDebug>
#include <QtGui>
#include <QtCore>
{ Q_OBJECT
public:
MainForm() {
connect(spinbox,SIGNAL(valueChanged(double)),this,SLOT(SpinBoxValueChanged(double)));
}
protected slots:
void SpinBoxValueChanged(double value) {
qDebug() << "Value changed";
}
private:
};
int main(int argc, char *argv[])
{
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
MainForm form;
form.setGeometry(100,100,800,600);
form.show();
return app.exec();
}
#include "main.moc"
Good luck!
Johannes
Re: QDialog show method's wierd problem on signal slot mechanism.
Aah..!! You do it yourself:
Code:
{
updateAxisValues();
updateCurveValues();
updateCurveSettings();
}
On first show.. this is called.. Thus updating all values.. Thus all ValueChanged-Slots are called..
If you want some other behaviour, you will have to change this :->
Johannes
Re: QDialog show method's wierd problem on signal slot mechanism.
Hi Johannes,
I have realized the explicit value change on controls in my update functions :D How dummy I am! Thanks so much for your helps. I solved this problem by kind of this codes;
Code:
ui.comboBoxCurveName->blockSignals(true); // For stop signal creation
ui.comboBoxCurveName->clear();
QwtPlotItemList plotItemList
= graph
->itemList
(QwtPlotItem::Rtti_PlotCurve);
for(QwtPlotItemIterator it = plotItemList.begin(); it != plotItemList.end(); it++)
{
ui.comboBoxCurveName->addItem(curve->title().text());
}
ui.comboBoxCurveName->blockSignals(false); // For start signal creation
So there is no signal while I am manipulating controls attributes.
Thanks again.
Regards.