Qt Forum

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

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

    General and Desktop
    moving background qwidget qgraphicsscene
    3
    5
    4512
    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.
    • Ganou_R
      Ganou_R last edited by

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        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_R 1 Reply Last reply Reply Quote 0
        • V
          VRonin last edited by 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)

          "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_R 1 Reply Last reply Reply Quote 0
          • Ganou_R
            Ganou_R @mrjj last edited by

            @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 Reply Quote 0
            • Ganou_R
              Ganou_R @VRonin last edited by

              @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 Reply Quote 0
              • First post
                Last post