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. Calculate FPS in GUI Application
Forum Updated to NodeBB v4.3 + New Features

Calculate FPS in GUI Application

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 2.9k Views 3 Watching
  • 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.
  • I Offline
    I Offline
    Infestor
    wrote on last edited by
    #1

    Hi,

    I was wondering if it somehow is possible to calculate the FPS in Qt. For it to work there has to be an event/a function that i can override that is called every frame. Is there something like that in Qt?

    Thanks in advance

    Pl45m4P 1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      Unless it's some sort of animation a typical ui does not have a constant refresh rate. It only refreshes when something changes. It doesn't even have to update entire window, just the part that changed, so talking in terms of FPS when it comes to ui is rather meaningless. You could of course do a "game style" ui that redraws everything at a constant rate, but that would be incredibly wasteful.

      What sort of app do you have in mind? Is it something like a full-window OpenGL, QML or a traditional widget based ui with panels, buttons and stuff?

      I 1 Reply Last reply
      2
      • I Infestor

        Hi,

        I was wondering if it somehow is possible to calculate the FPS in Qt. For it to work there has to be an event/a function that i can override that is called every frame. Is there something like that in Qt?

        Thanks in advance

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @Infestor

        You could measure the calls of your paint-Events per second, but as @Chris-Kawa said above, this only happens, when there is something that needs to be re-drawn


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        1
        • Chris KawaC Chris Kawa

          Unless it's some sort of animation a typical ui does not have a constant refresh rate. It only refreshes when something changes. It doesn't even have to update entire window, just the part that changed, so talking in terms of FPS when it comes to ui is rather meaningless. You could of course do a "game style" ui that redraws everything at a constant rate, but that would be incredibly wasteful.

          What sort of app do you have in mind? Is it something like a full-window OpenGL, QML or a traditional widget based ui with panels, buttons and stuff?

          I Offline
          I Offline
          Infestor
          wrote on last edited by Infestor
          #4

          @Chris-Kawa Thanks for the response. The applicaiton is a realtime simulation, but without openGL or QML (i.e. traditional) and i just wanted to display FPS to measure performance (usually it is a good indicator). Is there maybe another way to do this?

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by Chris Kawa
            #5

            It depends on what it uses for that simulation.
            FPS is just number of repaints per second so all you have to do is either count them and update every second or, if you need more frequency, you can measure time elapsed between draws and guesstimate by calculating 1/(frame delta).

            If it's a widget you could count paintEvent per second like @Pl45m4 said.If it's a QOpenGLWidget you could similarly count paintGL calls per second. Hard to say without knowing more about what you use and how you repaint.

            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