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. How to set a moving background (images) into my QWidget
Forum Update on Monday, May 27th 2025

How to set a moving background (images) into my QWidget

Scheduled Pinned Locked Moved Solved General and Desktop
movingbackgroundqwidgetqgraphicsscene
5 Posts 3 Posters 5.5k 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.
  • Ganou_RG Offline
    Ganou_RG Offline
    Ganou_R
    wrote on last edited by
    #1

    Hello everyone, I am relatively new to Qt Creator C++, and I would like to create a windows program (just a QWidget window) where the background is constantly moving from right to left. I found the perfect picture on the internet to illustrate what I mean:
    [logo]: http://moovitapp.com/fr/wp-content/uploads/sites/7/2014/06/moovit_windows-phone-screen.png "Phone image"

    I have thought about ways to do it, and I think I I should first create my own separate images, such the Sun, different clouds, and the buildings and then add them into my QWidget. Now my problem is how to make the clouds and buildings move recurrently (after a cloud has disappeared on the left, it appears again on the right) while the Sun stays stationary. I have no idea how to do this, but I guess I should start by creating a QGraphicsScene ? Or should I first learn Qt Quick ?

    Thank you for your help !

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

      hi and welcome
      Qt Quick/QML would be good for such animation
      but its also important to consider what rest of application should do.
      Is it a normal desktop program or more like a phone app ?

      QGraphicsScene could also work really well.

      So I would choose QML or QGraphicsScene based upon what else the app needs to do.

      Ganou_RG 1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by VRonin
        #3

        If it requires user interaction QML is probably the faster way, otherwise make the image a .gif use a QLabel as base and use setMovie() to load the gif (remember to start the movie)

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        Ganou_RG 1 Reply Last reply
        0
        • mrjjM mrjj

          hi and welcome
          Qt Quick/QML would be good for such animation
          but its also important to consider what rest of application should do.
          Is it a normal desktop program or more like a phone app ?

          QGraphicsScene could also work really well.

          So I would choose QML or QGraphicsScene based upon what else the app needs to do.

          Ganou_RG Offline
          Ganou_RG Offline
          Ganou_R
          wrote on last edited by
          #4

          @mrjj Hello, thank you for your quick answer. Well, first I would like to create a desktop program and consider a phone app later. I think I'll start by learning QML/Qt Quick then, as I've seen that the Qt Quick demo - Maroon in trouble is pretty much close to what I want to do

          1 Reply Last reply
          0
          • VRoninV VRonin

            If it requires user interaction QML is probably the faster way, otherwise make the image a .gif use a QLabel as base and use setMovie() to load the gif (remember to start the movie)

            Ganou_RG Offline
            Ganou_RG Offline
            Ganou_R
            wrote on last edited by
            #5

            @VRonin
            Hi
            Oh yeah, I didn't think about a .gif ! That will spare me the complication of trying to find a way to make the scene recurrent. Thank you !

            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