Important: Please read the Qt Code of Conduct -

[Solved] Placement and re-sizing of animated gif.

  • I am out of ideas. After hours at this either I have no idea what I am doing or Qt is broken. (3rd alternative is that animated gif in QMovies is just something that is not well supported.)

    I am trying to play back animated gifs as QMovies. They are all the same size. But I would like to resize some and move them around the screen. I am using code that looks something like this:

    // Resize the label if necessary.
    my_size = QSize(size_anim_x, size_anim_y);

    // Reposition the label if necessary.
    imgLabel->move(pos_anim_x, pos_anim_y);


    What appears to work is the re-sizing of the QLable imgLabel. Also, no matter what I try, the positioning of the QLable imgLabel does not appear to work. The QLable imgLabel appears to be always centered in the screen. Ahhh!

    Here is the layout that I used with the above code:


    QHBoxLayout *horz_layout = new QHBoxLayout;
    QVBoxLayout *layout = new QVBoxLayout;

    I thought about not using the "addStretch(0)" before and after the QLabel imgLabel. But when I remove them it appears that the QLabel imgLabel expands to the entire screen. Always. Even when I tell it to become small.

    Do any see something that I've done wrong?

    -thanks for any help

  • No one answered so I'll just post our work around.

    I could not get the above to work at all. I still think it should. And have no idea why it doesn't.

    What I finally did was to use style sheets and formed up a QString describing what I wanted to to. If I wanted to move the QLabel with the animated GIF around, I would use different numbers when creating the QString used in the style sheet command.


  • I'll change this to "solved" even though I believe the solution I used is a work around. What I would like to know is why my original approach did not work. With that kind of knowledge I'm thinking I could figure my way out of future problems. This way (using a work around) it feels a lot like guessing until something works.

Log in to reply