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 can not change file
Qt 6.11 is out! See what's new in the release blog

QMovie can not change file

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 606 Views
  • 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.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by sonichy
    #1

    I am write a program of GIFPlayer, but I can not change gif by open file on Linux Qt 5.6.1.

    void MainWindow::on_action_open_triggered()
    {
        filename = QFileDialog::getOpenFileName(this, "open file", ".", "GIF(*.gif)");
        if(!filename.isEmpty()){
            movie->setFileName(filename);
            ui->label->setMovie(movie);
            movie->start();
        }
    }
    

    https://github.com/sonichy

    RatzzR 1 Reply Last reply
    0
    • sonichyS sonichy

      I am write a program of GIFPlayer, but I can not change gif by open file on Linux Qt 5.6.1.

      void MainWindow::on_action_open_triggered()
      {
          filename = QFileDialog::getOpenFileName(this, "open file", ".", "GIF(*.gif)");
          if(!filename.isEmpty()){
              movie->setFileName(filename);
              ui->label->setMovie(movie);
              movie->start();
          }
      }
      
      RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by
      #2

      @sonichy

      I tried the same code its working here on windows Qt 5.9.3.

      --Alles ist gut.

      1 Reply Last reply
      0
      • sonichyS Offline
        sonichyS Offline
        sonichy
        wrote on last edited by
        #3

        On Windows Qt 5.8, the problem is the same.
        But I find another way to solve this problem:
        Run QMovie as background, connect frameChange, return currentPixmap()

        {
            QMovie movie = new QMovie;
            connect(movie,SIGNAL(frameChanged(int)),this,SLOT(frameChange(int)));
        }
        
        void MainWindow::loadImage(QString spath)
        {
            movie->stop();
            QString MIME = QMimeDatabase().mimeTypeForFile(spath).name();
            if(MIME == "image/gif"){
                movie->setFileName(spath);
                movie->start();
            }else{
                // bmp, jpg, png...
            }
        }
        
        void MainWindow::frameChange(int fn)
        {
            ui->label->setPixmap(movie->currentPixmap());
        }
        

        https://github.com/sonichy

        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