Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Unsolved Calculate FPS in GUI Application

    General and Desktop
    3
    5
    972
    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.
    • I
      Infestor last edited by

      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

      Pl45m4 1 Reply Last reply Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by 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 1 Reply Last reply Reply Quote 2
        • Pl45m4
          Pl45m4 @Infestor last edited by

          @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 Reply Quote 1
          • I
            Infestor @Chris Kawa last edited by Infestor

            @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 Reply Quote 0
            • Chris Kawa
              Chris Kawa Moderators last edited by Chris Kawa

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