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. Is there a way to make an object move with the same smooth look as the one displayed by the mac's screen saver?
Forum Updated to NodeBB v4.3 + New Features

Is there a way to make an object move with the same smooth look as the one displayed by the mac's screen saver?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 774 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.
  • stibo1950S Offline
    stibo1950S Offline
    stibo1950
    wrote on last edited by
    #1

    I'd like to reproduce the behavior of the screen saver available on the mac. It's about presenting pictures that move to occupy a part of the screen.
    To reproduce this behavior with Qt, I used QTimer which is called at each msec to execute the displacement of an object of the QLabel class containing the image (QPixmap). It works, but the problem is that the image flickers. To correct this problem I have reduced the step of the movement, but in this case the image refresh becomes too slow.
    To correct this problem, I tried to move the image in a loop, but the image only updates after the loop is finished, so you can't see the image moving. I tried to call QWidget::repaint(), but the image doesn't update.

    Is there a way to make an object move with the same smooth look as the one displayed by the mac's screen saver?

    JonBJ 1 Reply Last reply
    0
    • stibo1950S stibo1950

      I'd like to reproduce the behavior of the screen saver available on the mac. It's about presenting pictures that move to occupy a part of the screen.
      To reproduce this behavior with Qt, I used QTimer which is called at each msec to execute the displacement of an object of the QLabel class containing the image (QPixmap). It works, but the problem is that the image flickers. To correct this problem I have reduced the step of the movement, but in this case the image refresh becomes too slow.
      To correct this problem, I tried to move the image in a loop, but the image only updates after the loop is finished, so you can't see the image moving. I tried to call QWidget::repaint(), but the image doesn't update.

      Is there a way to make an object move with the same smooth look as the one displayed by the mac's screen saver?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @stibo1950 said in Is there a way to make an object move with the same smooth look as the one displayed by the mac's screen saver?:

      I tried to call QWidget::repaint()

      On this point alone, you might want to try QWidget::update() instead:

      This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop. This permits Qt to optimize for more speed and less flicker than a call to repaint() does.

      You will have to allow events to process, I don't know if that will be fast enough, you could try and see.

      It may be that you need something faster than widget label/pixmap approach to achieve what you want, I don't know. (Is this what OpenGL is about? Gfx acceleration? QGraphics stuff? You can see I'm stumbling :-) )

      stibo1950S 1 Reply Last reply
      0
      • JonBJ JonB

        @stibo1950 said in Is there a way to make an object move with the same smooth look as the one displayed by the mac's screen saver?:

        I tried to call QWidget::repaint()

        On this point alone, you might want to try QWidget::update() instead:

        This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop. This permits Qt to optimize for more speed and less flicker than a call to repaint() does.

        You will have to allow events to process, I don't know if that will be fast enough, you could try and see.

        It may be that you need something faster than widget label/pixmap approach to achieve what you want, I don't know. (Is this what OpenGL is about? Gfx acceleration? QGraphics stuff? You can see I'm stumbling :-) )

        stibo1950S Offline
        stibo1950S Offline
        stibo1950
        wrote on last edited by
        #3

        Thank you for your advice.

        On this point alone, you might want to try QWidget::update() instead:

        This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop. This permits Qt to optimize for more speed and less flicker than a call to repaint() does.

        I tried QWidget::update(), but it doesn't update the image immediately as I want to do. Using QWidget::repaint(), I was trying to force an immediate update of the image.

        You will have to allow events to process, I don't know if that will be fast enough, you could try and see.

        Using QTimer to force the recall of my method that moves the image, the speed is far to be sufficient.

        It may be that you need something faster than widget label/pixmap approach to achieve what you want, I don't know. (Is this what OpenGL is about? Gfx acceleration? QGraphics stuff? You can see I'm stumbling :-) )

        This is what I'm looking for. If anyone knows a solution and can tell me where to find examples of it, I'll take it.
        Thanks

        JonBJ 1 Reply Last reply
        0
        • stibo1950S stibo1950

          Thank you for your advice.

          On this point alone, you might want to try QWidget::update() instead:

          This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop. This permits Qt to optimize for more speed and less flicker than a call to repaint() does.

          I tried QWidget::update(), but it doesn't update the image immediately as I want to do. Using QWidget::repaint(), I was trying to force an immediate update of the image.

          You will have to allow events to process, I don't know if that will be fast enough, you could try and see.

          Using QTimer to force the recall of my method that moves the image, the speed is far to be sufficient.

          It may be that you need something faster than widget label/pixmap approach to achieve what you want, I don't know. (Is this what OpenGL is about? Gfx acceleration? QGraphics stuff? You can see I'm stumbling :-) )

          This is what I'm looking for. If anyone knows a solution and can tell me where to find examples of it, I'll take it.
          Thanks

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @stibo1950 said in Is there a way to make an object move with the same smooth look as the one displayed by the mac's screen saver?:

          I tried QWidget::update(), but it doesn't update the image immediately as I want to do.

          It would if you allow processing of events.

          1 Reply Last reply
          0
          • stibo1950S Offline
            stibo1950S Offline
            stibo1950
            wrote on last edited by
            #5

            Thanks, Jon. I'm a new user of Qt and your comment forced me to look into how to allow Qt to process image movements. I now call QCoreApplication::processEvents() and it works, except that moving the image is slow and lacks fluidity.
            So I'm going to look for another way to do it. I am currently reading something about the QPropertyAnimation class.
            If I find a good way to move pictures, I'll report it here.
            Best Regards.

            JonBJ 1 Reply Last reply
            1
            • stibo1950S stibo1950

              Thanks, Jon. I'm a new user of Qt and your comment forced me to look into how to allow Qt to process image movements. I now call QCoreApplication::processEvents() and it works, except that moving the image is slow and lacks fluidity.
              So I'm going to look for another way to do it. I am currently reading something about the QPropertyAnimation class.
              If I find a good way to move pictures, I'll report it here.
              Best Regards.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @stibo1950 said in Is there a way to make an object move with the same smooth look as the one displayed by the mac's screen saver?:

              I now call QCoreApplication::processEvents() and it works, except that moving the image is slow and lacks fluidity.

              Which is about what I suspected :)

              reading something about the QPropertyAnimation class.

              Beyond my pay grade, but this looks good. Also people doing smoothy-animationy things seem to use QML/QtQuick, I have no idea whether that is relevant to you. Perhaps just hav a look for ideas at https://forum.qt.io/topic/72495/simple-screen-saver ?

              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