Unsolved 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'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?
-
@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 :-) ) -
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 -
@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.
-
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. -
@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 ?