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. [Solved] Placement and re-sizing of animated gif.

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 4.1k Views 1 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.
  • S Offline
    S Offline
    st2000
    wrote on last edited by
    #1

    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:
    @
    imgLabel->clear();
    imgLabel->setMovie(apt_movie);

    // Resize the label if necessary.
    imgLabel->setScaledContents(true);
    my_size = QSize(size_anim_x, size_anim_y);
    imgLabel->resize(my_size);

    // 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:

    @
    imgLabel->setMovie(apt_movie);

    QHBoxLayout *horz_layout = new QHBoxLayout;
    
    horz_layout->addStretch(0);
    horz_layout->addWidget(imgLabel);
    horz_layout->addStretch(0);
    horz_layout->setMargin(0);
    horz_layout->setSpacing(0);
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addStretch(0);
    layout->addLayout(horz_layout);
    layout->addStretch(0);
    layout->setMargin(0);
    layout->setSpacing(0);
    setLayout(layout);@
    

    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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      st2000
      wrote on last edited by
      #2

      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.

      -thanks

      1 Reply Last reply
      0
      • S Offline
        S Offline
        st2000
        wrote on last edited by
        #3

        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.

        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