Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Connecting a called pointer's signal
Forum Updated to NodeBB v4.3 + New Features

Connecting a called pointer's signal

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 394 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Dummie1138D Offline
    Dummie1138D Offline
    Dummie1138
    wrote on last edited by Dummie1138
    #1

    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.

    J.HilkJ 1 Reply Last reply
    0
    • Dummie1138D Dummie1138

      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.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @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


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      Dummie1138D 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @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

        Dummie1138D Offline
        Dummie1138D Offline
        Dummie1138
        wrote on last edited by
        #3

        @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.

        jsulmJ 1 Reply Last reply
        0
        • Dummie1138D Dummie1138

          @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.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Dummie1138 said in Connecting a called pointer's signal:

          What exactly do you mean by return value of connect?

          connect() returns a boolean...

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          Dummie1138D 1 Reply Last reply
          1
          • jsulmJ jsulm

            @Dummie1138 said in Connecting a called pointer's signal:

            What exactly do you mean by return value of connect?

            connect() returns a boolean...

            Dummie1138D Offline
            Dummie1138D Offline
            Dummie1138
            wrote on last edited by
            #5

            @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.

            J.HilkJ 1 Reply Last reply
            0
            • Dummie1138D Dummie1138

              @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.

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by J.Hilk
              #6

              @Dummie1138 what does loopCount() return ? maybe its set to -1 Than QMovie probably never emits the finished signal, as it never finishes :D


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              Dummie1138D 1 Reply Last reply
              2
              • J.HilkJ J.Hilk

                @Dummie1138 what does loopCount() return ? maybe its set to -1 Than QMovie probably never emits the finished signal, as it never finishes :D

                Dummie1138D Offline
                Dummie1138D Offline
                Dummie1138
                wrote on last edited by
                #7

                @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.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved