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. background
Forum Update on Monday, May 27th 2025

background

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 530 Views
  • 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
    Sannan
    wrote on last edited by
    #1

    someone please tell me that how to set a gif image on my centralwidget

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Just put a Qlabel there and set the GIF via setPixmap
      If you mean an animated gif, have a look at QMovie.
      https://doc.qt.io/qt-5/qmovie.html

      alt text

      You can also set it to central with

          QPixmap pix(":/test.gif"); // note this is from an ressource file    
           QLabel *label = new QLabel;    
            label->setPixmap(pix);    
            label->setScaledContents(true);    
            setCentralWidget(label);
      

      alt text

      1 Reply Last reply
      4
      • S Offline
        S Offline
        Sannan
        wrote on last edited by
        #3

        Thanks alot sir

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sannan
          wrote on last edited by
          #4

          Ah!! sir one more thing i want set an animated gif on the background and i was able to do it with the help of qmovie on qlabel but when i want to add a pushbutton or anything else it doesn't appear on the screenAnnotation 2019-10-08 064225.png

          after running i got this
          Annotation 2019-10-08 064327.png
          you see there is no pushbutton on main form

          the code i have written is
          ```
          *this->setCentralWidget(ui->label);
          QMovie movie = new QMovie(":/Images/7T9364v.gif");
          ui->label->setMovie(movie);
          movie->start();
          ui->label->setScaledContents(true);

          1 Reply Last reply
          0
          • Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by Kent-Dorfman
            #5

            Think about what would be required to allow pushbuttons over top of an animated image. every time the background image frame is updated, all the higher z-order widgets would need to be checked and potentially repainted. From a programmatic perspective I would avoid adding widgets over top of an animation.

            You also need to consider that the animation and buttons are part of the same layout. If you really want buttons on an animation, shouldn't those buttons be children of the image, instead of peers in the parent layout?

            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