QMovie can not change file
Solved
General and Desktop
-
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(); } }
-
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()); }