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. QMovie not starting

QMovie not starting

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 785 Views 2 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
    #1

    Hi. I have a QMovie that is stuck in the QMovie::NotRunning state. To be specific, this is my code. The QMovie does not display on the ui, if that helps.

        QMovie *movie = new QMovie("images/nope.gif");
        //Read size of gif then reset size based on the ratio
        movie->setScaledSize(ui->loadingLabel->size());
        ui->loadingLabel->setMovie(movie);
        ui->loadingLabel->movie()->start();
        qDebug() << "welpMovie " << movie->state();
        movie->setPaused(true);
        connect(ui->loadingLabel->movie(), SIGNAL(finished()), this, SLOT(setPaused()));
        qDebug() << movie->loopCount();
    

    This is the output when this code is run:

    welpMovie  QMovie::NotRunning
    -1
    

    Please let me know if more information is required, I am not sure where to begin. So far, I have also tried the following, which was ineffective:

    movie->start();
    qDebug() << "welpMovie " << movie->state();
    

    Output: welpMovie QMovie::NotRunning

    jsulmJ 1 Reply Last reply
    0
    • Dummie1138D Dummie1138

      Hi. I have a QMovie that is stuck in the QMovie::NotRunning state. To be specific, this is my code. The QMovie does not display on the ui, if that helps.

          QMovie *movie = new QMovie("images/nope.gif");
          //Read size of gif then reset size based on the ratio
          movie->setScaledSize(ui->loadingLabel->size());
          ui->loadingLabel->setMovie(movie);
          ui->loadingLabel->movie()->start();
          qDebug() << "welpMovie " << movie->state();
          movie->setPaused(true);
          connect(ui->loadingLabel->movie(), SIGNAL(finished()), this, SLOT(setPaused()));
          qDebug() << movie->loopCount();
      

      This is the output when this code is run:

      welpMovie  QMovie::NotRunning
      -1
      

      Please let me know if more information is required, I am not sure where to begin. So far, I have also tried the following, which was ineffective:

      movie->start();
      qDebug() << "welpMovie " << movie->state();
      

      Output: welpMovie QMovie::NotRunning

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

      @Dummie1138 said in QMovie not starting:

      ui->loadingLabel->movie()->start();
      qDebug() << "welpMovie " << movie->state();

      You are calling state() right after calling start(). This will not work - start() is asynchronous. You need to connect a slot to https://doc.qt.io/qt-6/qmovie.html#stateChanged to get state updates when they occur.
      And you really should use newer Qt5 connect syntax.

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

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Beside the excellent point of @jsulm, you are using a relative path so unless you ensure that the file is beside the executable at that path when you start your application, it won't find it.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

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