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
{
Q_OBJECT
.............
public slots:
void reSize();
signals:
void getSize();
...........
}
class MyWidget : public QWidget
{
Q_OBJECT
.............
public slots:
void reSize();
signals:
void getSize();
...........
}
To copy to clipboard, switch view to plain text mode
constructor in main.cpp
................
connect(this, SIGNAL(getSize()), this, SLOT(reSize()));
...............
................
connect(this, SIGNAL(getSize()), this, SLOT(reSize()));
...............
To copy to clipboard, switch view to plain text mode
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
}
...........
...........
void MyWidget::function1()
{
emit getSize();
emit getSize();//both emit's are needed!!
}
void MyWidget::reSize()
{
resize(x,y);//x and y are global variables
}
...........
To copy to clipboard, switch view to plain text mode
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. ??
Bookmarks