Gifs on Sailfish-os

557 views Asked by At

I came here with a little problem, i can't use any local .gif in my code.

I work on Linux with QtCreator and the Sailfish VM to make a Sailfish-os application.

I tried first this example, without any success.

Rectangle {
    width: animation.width
    height: animation.height

    AnimatedImage { id: animation; source: "../images/animatedimageitem.gif"}
}

The execution return :

QML AnimatedImage: Error Reading Animated Image File file:///bla/bla/.....

Same problem with other permissions on the gif and with an other gif.

After some researches I found this page where someone indicate to download a plugin, but Qt declare (I wish i could put a link but i'm new -_-', see comments) that gifs are already support by default.

The plugin was finally unobtainable and I found this Sailfish/bin/plugins/imageformats/libqgif.so in my directories.

So what can i do to show a gif on this damn thing ?

2

There are 2 answers

2
Psycho On BEST ANSWER

Well..... I just put it on my phone (Jolla) and the gif works well. So this is the VM who doesn't seems to like gifs ...

Thanks for help though, Psycho.

2
BaCaRoZzo On

The error you are seeing is probably related to filepaths. Gifs are supported, AFAIK.

Instead of coding the path that way, consider the usage of a resource file to improve portability and platform independence.

  • Create a new resource file (File -> New File or project -> Qt -> Qt Resource File)
  • The property editor opens, click Add in the bottom then Add prefix and set a prefix such as / (or whatever you like!)
  • Click again to select Add files and insert your image
  • Right-click the newly added image entry and copy resource path to Clipboard
  • Build -> Run qmake (fundamental to ensure correct compilation)

The path you copied in the clipboard should be of the form:

://PATH_TO_IMAGE.gif

Now, given your QML code, I can guess the image folder is inside source code at the same level as the QML folder. Hence, if you added the .gif file from that folder you would have the following path in the clipboard:

://images/name.gif

This can be prepended with the prefix to obtain the final path. If your prefix is set to /, as we did above, the final string to be set in the source property of your AnimatedImage would be:

"qrc:///images/name.gif"

Obviously, a different prefix or a different path would result in a different final path.