Connecting a called pointer's signal
-
Hi. I have a QLabel displaying a QMovie.
QMovie *movie = new QMovie("images/Nope.gif"); movie->setScaledSize(ui->loadingLabel->size()); ui->loadingLabel->setMovie(movie); movie->start(); movie->setPaused(true);
I have another function that is meant to stop the movie after a label is modified, which is the following.
void ApplicationSettings::on_combo_changeLabel_textActivated(const QString &arg1) { QString currentText = arg1; qDebug() << ui->loadingLabel->movie() << "txtac"; connect(ui->loadingLabel->movie(), SIGNAL(finished()), this, SLOT(setPaused())); ui->loadingLabel->movie()->start(); qDebug() << "Thing connected"; } void ApplicationSettings::setPaused(){ ui->loadingLabel->movie()->setPaused(true); qDebug() << "in paused"; }
My output is:
QMovie(0x7c78428) txtac Thing connected
I believe I have not properly connected the signal and the slot, but I am not sure how exactly did I mess up. It may be because I am calling the pointer that needs connected to, but I am not sure how this might affect things. Please let me know if more information is required.
-
Hi. I have a QLabel displaying a QMovie.
QMovie *movie = new QMovie("images/Nope.gif"); movie->setScaledSize(ui->loadingLabel->size()); ui->loadingLabel->setMovie(movie); movie->start(); movie->setPaused(true);
I have another function that is meant to stop the movie after a label is modified, which is the following.
void ApplicationSettings::on_combo_changeLabel_textActivated(const QString &arg1) { QString currentText = arg1; qDebug() << ui->loadingLabel->movie() << "txtac"; connect(ui->loadingLabel->movie(), SIGNAL(finished()), this, SLOT(setPaused())); ui->loadingLabel->movie()->start(); qDebug() << "Thing connected"; } void ApplicationSettings::setPaused(){ ui->loadingLabel->movie()->setPaused(true); qDebug() << "in paused"; }
My output is:
QMovie(0x7c78428) txtac Thing connected
I believe I have not properly connected the signal and the slot, but I am not sure how exactly did I mess up. It may be because I am calling the pointer that needs connected to, but I am not sure how this might affect things. Please let me know if more information is required.
@Dummie1138 you're using old connect syntax, so do you have
setPaused
marked as a slot ? Inside your header,Also check the return value of the connect call, see if its true or false
-
@Dummie1138 you're using old connect syntax, so do you have
setPaused
marked as a slot ? Inside your header,Also check the return value of the connect call, see if its true or false
@J-Hilk I do have setPaused marked in a private slot.
What exactly do you mean by return value of connect? Both functions and the signal are voids.
-
@J-Hilk I do have setPaused marked in a private slot.
What exactly do you mean by return value of connect? Both functions and the signal are voids.
@Dummie1138 said in Connecting a called pointer's signal:
What exactly do you mean by return value of connect?
connect() returns a boolean...
-
@Dummie1138 said in Connecting a called pointer's signal:
What exactly do you mean by return value of connect?
connect() returns a boolean...
@jsulm I did not even think of that, thanks!
In my case, my connect returns a true. According to the documentation I'm assuming the connection is valid then? In that case I will look into other potential reasons for the slot not being called.
-
@jsulm I did not even think of that, thanks!
In my case, my connect returns a true. According to the documentation I'm assuming the connection is valid then? In that case I will look into other potential reasons for the slot not being called.
@Dummie1138 what does
loopCount()
return ? maybe its set to -1 Than QMovie probably never emits the finished signal, as it never finishes :D -
@Dummie1138 what does
loopCount()
return ? maybe its set to -1 Than QMovie probably never emits the finished signal, as it never finishes :D@J-Hilk Yeah, I just tried swapping to framechanged(int), which paused it right away. I'll try to mess with my QMovie or the gif so that it can actually know when to finish.