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 display pictures real time in Qt?
QtWS25 Last Chance

Is there a way to display pictures real time in Qt?

Scheduled Pinned Locked Moved Unsolved General and Desktop
realtimediplaydelay
5 Posts 4 Posters 570 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.
  • L Offline
    L Offline
    lrq1009962019
    wrote on 1 Feb 2024, 04:04 last edited by
    #1

    I'm trying to use QTimer to call QLabel's setPixmap() every 5ms to update it in the UI, but the slot function of QTimer is not called every 5ms, and it takes much longer. Similarly, I tested the time interval between two paintEvent() calls of QLabel and found it to be about 20ms, which makes it impossible for me to update the UI in real time. But the call of paintEvent() only cost less than 0.1 ms. And I have moved the image rendering task to a subthread, and there are no other time-consuming operations in the slot function of the QTimer, only the call to setPixmap(). I wonder if there is any ohter way to make paintEvent() called more frequently, or should I use another way to display the pictures in real time?

    J 1 Reply Last reply 1 Feb 2024, 06:22
    0
    • L lrq1009962019
      1 Feb 2024, 04:04

      I'm trying to use QTimer to call QLabel's setPixmap() every 5ms to update it in the UI, but the slot function of QTimer is not called every 5ms, and it takes much longer. Similarly, I tested the time interval between two paintEvent() calls of QLabel and found it to be about 20ms, which makes it impossible for me to update the UI in real time. But the call of paintEvent() only cost less than 0.1 ms. And I have moved the image rendering task to a subthread, and there are no other time-consuming operations in the slot function of the QTimer, only the call to setPixmap(). I wonder if there is any ohter way to make paintEvent() called more frequently, or should I use another way to display the pictures in real time?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 1 Feb 2024, 06:22 last edited by
      #2

      @lrq1009962019 said in Is there a way to display pictures real time in Qt?:

      every 5ms to update it in the UI

      You want to update the picture 200 times per second? Why? Most displays refresh at 60Hz, some go up to 120Hz.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SimonSchroeder
        wrote on 2 Feb 2024, 07:47 last edited by
        #3

        I guess that setPixmap() internally calls update(). update() will collect several calls before actually issuing a paint event. If you want to trigger the paint event immediately you need to call repaint(). However, doing this too often will result in a sluggish UI.

        Nevertheless, @jsulm is right: 60Hz for a display means that only roughly every 16ms the screen is redrawn. You cannot physically display a new image every 5ms. And even if you could, humans are not able to perceive this. The best you can do is to drop the image you are not able to display. You would need a 240Hz display to show a new image every 5ms. These are gaming monitors (a lot of them with false advertising, i.e. 240Hz refresh rate of the backlight). Qt is not made for such high through put (though it might work). Instead you should be looking at game development using Vulkan, Metal or DirectX (depending on your OS) to achieve fast graphical performance, if this is really what you want.

        1 Reply Last reply
        1
        • J Offline
          J Offline
          JonB
          wrote on 2 Feb 2024, 09:16 last edited by
          #4

          Interestingly (to me, at least), and quite irrelevant so forgive me, but apparently chimpanzees can see and react to screen pictures much, much faster than humans. You're not aiming your application at them, are you? ;-)

          J 1 Reply Last reply 2 Feb 2024, 14:23
          1
          • J JonB
            2 Feb 2024, 09:16

            Interestingly (to me, at least), and quite irrelevant so forgive me, but apparently chimpanzees can see and react to screen pictures much, much faster than humans. You're not aiming your application at them, are you? ;-)

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 2 Feb 2024, 14:23 last edited by
            #5

            @JonB Same applies to flies :-D

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1

            1/5

            1 Feb 2024, 04:04

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved