eric
21st January 2008, 22:12
I have a situation where a signal needs to be emitted twice before it triggers slot action. Does anyone know why? This is what I have:
*.h file
class MyWidget : public QWidget
{
Q_OBJECT
.............
public slots:
void reSize();
signals:
void getSize();
...........
}
constructor in main.cpp
................
connect(this, SIGNAL(getSize()), this, SLOT(reSize()));
...............
functions.cpp
...........
void MyWidget::function1()
{
emit getSize();
emit getSize();//both emit's are needed!!
}
void MyWidget::reSize()
{
resize(x,y);//x and y are global variables
}
...........
The amazing thing is that I need to emit the signal twice. If it is emitted once, the resize function (in function2()) is not executed. ??
*.h file
class MyWidget : public QWidget
{
Q_OBJECT
.............
public slots:
void reSize();
signals:
void getSize();
...........
}
constructor in main.cpp
................
connect(this, SIGNAL(getSize()), this, SLOT(reSize()));
...............
functions.cpp
...........
void MyWidget::function1()
{
emit getSize();
emit getSize();//both emit's are needed!!
}
void MyWidget::reSize()
{
resize(x,y);//x and y are global variables
}
...........
The amazing thing is that I need to emit the signal twice. If it is emitted once, the resize function (in function2()) is not executed. ??