Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved Animated gif inside QLabel not be drawn transparently

    General and Desktop
    4
    9
    1597
    Loading More Posts
    • 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.
    • T
      Taytoo last edited by

      I have a QWidget 'A' with a background-image set in its stylesheet - nothing else is drawn on it. On top of the QWidget I have a QLabel widget (children of the 'A') with background set to Transparent. I'm playing an animated gif inside this QLabel using QMovie, the gif itself has transparency (spinner effect).

      When I run the application it looks like the spinner is continuously being drawn on itself without background of the parent being re-drawn first? Then I just tried displaying a text in the Label, but even with just text, the background of the parent is Not being drawn. How do I fix these issues?

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        Hi
        Make sure your stylesheet doesn't also affect the Label by using
        too broad selector.

        QWidget#centralWidget {
        background-image: url(:/garden.jpg);
        }

        Works fine for fast test.
        alt text

        S 1 Reply Last reply Reply Quote 3
        • T
          Taytoo last edited by

          I was able to solve the background not drawing issue by painting the jpg manually - I had to do it because I wanted to custom fit the background.

          The issue I'm seeing now are the white areas around the edges, as you see in your gif as well. Looks like the edges are not per-pixel alpha-blended with the background?

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @Taytoo last edited by mrjj

            @Taytoo
            Nope, its not. Gif cannot do multilevel transparency.

            T 1 Reply Last reply Reply Quote 0
            • T
              Taytoo @mrjj last edited by Taytoo

              @mrjj Any ideas, how to fix this/workarounds?

              1 Reply Last reply Reply Quote 0
              • T
                Taytoo last edited by

                Found this answer on stackoverflow: https://stackoverflow.com/questions/24592918/gif-image-in-qlabel

                Although it was related to Graphics Scene, I tried it out, still no luck :(

                J.Hilk 1 Reply Last reply Reply Quote 0
                • J.Hilk
                  J.Hilk Moderators @Taytoo last edited by

                  @Taytoo you could potentially do it manually.
                  Save the gif frames as images, overwrite the paint event and draw one of the images. Set a timer to change the image periodically.

                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

                  Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply Reply Quote 1
                  • S
                    Sakshi053 @mrjj last edited by

                    @mrjj How did you made this gif work i'm also using a gif with transparent background but its not working ?

                    mrjj 1 Reply Last reply Reply Quote 0
                    • mrjj
                      mrjj Lifetime Qt Champion @Sakshi053 last edited by

                      @Sakshi053
                      Nothing special. JUst using QMovie.
                      Try the test project and see

                      https://www.dropbox.com/s/ebdoleidabqi3ci/stylesheetTest.zip?dl=0

                      1 Reply Last reply Reply Quote 1
                      • First post
                        Last post