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. Performance of QPainter?
Qt 6.11 is out! See what's new in the release blog

Performance of QPainter?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 7 Posters 6.4k Views 5 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.
  • K Offline
    K Offline
    Kamajii
    wrote on last edited by
    #1

    Hi,

    I was musing about the current (future) situation of QPainter , and whether I should use it as the principal painting engine for a new graphics-intense project or use a third-party library for the painting (except for the widgets, of course).

    QPainter is fine and deeply anchorend in the classic widgets so it will stay with us for a while for sure. However, I am uncertain about its performance nowadays. I remember it's got an OpenGL backend a while back, though, but I can't tell if there is much development going on. Will it stay with OpenGL? Vulkan, eventually?
    Generally I consider QPainter to be a mature and very comfortable tool, and I really like to work with it. Alas, there is not so much to choose from. Cairo seems a bit in need for active development, too, for instance, Blend2D is fast but AFAIK lacks most of the outstanding clipping features of QPainter. Skia is very similar to QPainter.

    Your thoughts on this are very welcome.

    Kind regards and Happy New Year,
    Sven

    A 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and happy new year !

      Did you already take a look at the Graphics topice in Qt's documentation ? It contains the current information about the tech stack used and what you can do with it. It might have some answers to the questions you have.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • K Offline
        K Offline
        Kamajii
        wrote on last edited by
        #3

        Hey SGaist,

        thanks for the pointer. Yes, I dug through the documentation (IMHO, Qt API has one of the best and most concise documentation that I know), but that kind of raised my concern.
        It all seems to revolve around QtQuick now, and QWidgets/QPainter seems to be a bit sidelined somehow.
        I'm not really sure if the traditional rendering stack has been touched for a while. Not that this is a bad thing by itself, it seems to run quite flawlessly.

        I'm just worried that it stays that way in the foreseeable future...

        JKSHJ 1 Reply Last reply
        0
        • S Offline
          S Offline
          SamiV123
          wrote on last edited by
          #4

          Depends a lot what your particular use case is but the good news is that if you do choose to use QPainter you can always easily integrate it with your own native OpenGL code and shaders.

          1 Reply Last reply
          0
          • K Kamajii

            Hey SGaist,

            thanks for the pointer. Yes, I dug through the documentation (IMHO, Qt API has one of the best and most concise documentation that I know), but that kind of raised my concern.
            It all seems to revolve around QtQuick now, and QWidgets/QPainter seems to be a bit sidelined somehow.
            I'm not really sure if the traditional rendering stack has been touched for a while. Not that this is a bad thing by itself, it seems to run quite flawlessly.

            I'm just worried that it stays that way in the foreseeable future...

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            @Kamajii said in Performance of QPainter?:

            I remember it's got an OpenGL backend a while back, though, but I can't tell if there is much development going on. Will it stay with OpenGL? Vulkan, eventually?

            Do you mean: The ability to use QPainter in QOpenGLWidget?

            Qt has mostly moved away from using a single graphics backend directly, towards using the Rendering Hardware Interface (RHI). A proof-of-concept has been made to port QPainter to the RHI, but it hasn't been polished yet (and it has been ~5 years unfortunately): https://bugreports.qt.io/browse/QTBUG-74407

            @Kamajii said in Performance of QPainter?:

            It all seems to revolve around QtQuick now, and QWidgets/QPainter seems to be a bit sidelined somehow.

            Qt Quick is currently the main thing that uses the Rendering Hardware Interface (RHI), but it's not the only thing.

            • Qt 3D (now deprecated) uses the RHI too
            • QRhiWidget lets you display (non-Qt Quick) RHI content in a QWidget

            And this example shows how to use QPainter (+ QImage) to paint things into the RHI: https://doc.qt.io/qt-6/qtwidgets-rhi-cuberhiwidget-example.html

            But to answer your main question about QPainter's performance: Since QPainter is currently designed for software rendering, it will likely be a bottleneck in a graphics-intensive project today. This could change if/when work on QTBUG-74407 is completed.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            K 1 Reply Last reply
            3
            • JKSHJ JKSH

              @Kamajii said in Performance of QPainter?:

              I remember it's got an OpenGL backend a while back, though, but I can't tell if there is much development going on. Will it stay with OpenGL? Vulkan, eventually?

              Do you mean: The ability to use QPainter in QOpenGLWidget?

              Qt has mostly moved away from using a single graphics backend directly, towards using the Rendering Hardware Interface (RHI). A proof-of-concept has been made to port QPainter to the RHI, but it hasn't been polished yet (and it has been ~5 years unfortunately): https://bugreports.qt.io/browse/QTBUG-74407

              @Kamajii said in Performance of QPainter?:

              It all seems to revolve around QtQuick now, and QWidgets/QPainter seems to be a bit sidelined somehow.

              Qt Quick is currently the main thing that uses the Rendering Hardware Interface (RHI), but it's not the only thing.

              • Qt 3D (now deprecated) uses the RHI too
              • QRhiWidget lets you display (non-Qt Quick) RHI content in a QWidget

              And this example shows how to use QPainter (+ QImage) to paint things into the RHI: https://doc.qt.io/qt-6/qtwidgets-rhi-cuberhiwidget-example.html

              But to answer your main question about QPainter's performance: Since QPainter is currently designed for software rendering, it will likely be a bottleneck in a graphics-intensive project today. This could change if/when work on QTBUG-74407 is completed.

              K Offline
              K Offline
              Kamajii
              wrote on last edited by
              #6

              @JKSH said in Performance of QPainter?:

              Do you mean: The ability to use QPainter in QOpenGLWidget?

              I think so, AFAIK that's the intended way to make use of QPainter's accelerated painting through OpenGL.

              Qt has mostly moved away from using a single graphics backend directly, towards using the Rendering Hardware Interface (RHI). A proof-of-concept has been made to port QPainter to the RHI, but it hasn't been polished yet (and it has been ~5 years unfortunately): https://bugreports.qt.io/browse/QTBUG-74407

              And that's exactly what I'm musing about :-S It's working great I think, but it's just been sitting there eversince. So I suppose what eventually will/should happen is that QPainter also gets an RHI backend.

              This could change if/when work on QTBUG-74407 is completed.

              Like I said I don't think there are many equally-capable painters out there at the moment, unfortunately.

              1 Reply Last reply
              0
              • K Kamajii

                Hi,

                I was musing about the current (future) situation of QPainter , and whether I should use it as the principal painting engine for a new graphics-intense project or use a third-party library for the painting (except for the widgets, of course).

                QPainter is fine and deeply anchorend in the classic widgets so it will stay with us for a while for sure. However, I am uncertain about its performance nowadays. I remember it's got an OpenGL backend a while back, though, but I can't tell if there is much development going on. Will it stay with OpenGL? Vulkan, eventually?
                Generally I consider QPainter to be a mature and very comfortable tool, and I really like to work with it. Alas, there is not so much to choose from. Cairo seems a bit in need for active development, too, for instance, Blend2D is fast but AFAIK lacks most of the outstanding clipping features of QPainter. Skia is very similar to QPainter.

                Your thoughts on this are very welcome.

                Kind regards and Happy New Year,
                Sven

                A Offline
                A Offline
                Asperamanca
                wrote on last edited by Asperamanca
                #7

                @Kamajii said in Performance of QPainter?:

                I was musing about the current (future) situation of QPainter , and whether I should use it as the principal painting engine for a new graphics-intense project

                No
                QPainter has terrible performance on some use cases (like multi-pixel width cosmetic pens)

                @Kamajii said in Performance of QPainter?:

                It all seems to revolve around QtQuick now, and QWidgets/QPainter seems to be a bit sidelined somehow.

                That's right. QPainter is going to stay in a stable state, but don't expect any improvements.

                @Kamajii said in Performance of QPainter?:

                So I suppose what eventually will/should happen is that QPainter also gets an RHI backend.

                I don't see that happening like, ever.

                I have made the transition from QGraphicsView (which uses QPainter) to QtQuick a few years ago, and I haven't looked back. You can get really great performance by building a QML scene with custom-drawn, C++-written QQuickItems.

                EDIT: I should add that the documentation for writing QQuickItems in C++ using SceneGraph is...lacking. There are a few blog posts by KDAB to help, if I remember correctly.

                F 1 Reply Last reply
                4
                • A Asperamanca

                  @Kamajii said in Performance of QPainter?:

                  I was musing about the current (future) situation of QPainter , and whether I should use it as the principal painting engine for a new graphics-intense project

                  No
                  QPainter has terrible performance on some use cases (like multi-pixel width cosmetic pens)

                  @Kamajii said in Performance of QPainter?:

                  It all seems to revolve around QtQuick now, and QWidgets/QPainter seems to be a bit sidelined somehow.

                  That's right. QPainter is going to stay in a stable state, but don't expect any improvements.

                  @Kamajii said in Performance of QPainter?:

                  So I suppose what eventually will/should happen is that QPainter also gets an RHI backend.

                  I don't see that happening like, ever.

                  I have made the transition from QGraphicsView (which uses QPainter) to QtQuick a few years ago, and I haven't looked back. You can get really great performance by building a QML scene with custom-drawn, C++-written QQuickItems.

                  EDIT: I should add that the documentation for writing QQuickItems in C++ using SceneGraph is...lacking. There are a few blog posts by KDAB to help, if I remember correctly.

                  F Offline
                  F Offline
                  F_Mehmood
                  wrote on last edited by
                  #8

                  @Asperamanca How tricky was it to make the transition from QGraphicsView/QGraphicsScene/QGraphicsItem to QtQuick? I am currently trying to do it but my current implementation is so qpainter focused that i am not even sure i can make the switch. I tried to look at QQuickPaintedItem but I am not sure if it uses hardware acceleration or not. Would i have to use something like QQuickRhiItem?

                  1 Reply Last reply
                  0
                  • GrecKoG Offline
                    GrecKoG Offline
                    GrecKo
                    Qt Champions 2018
                    wrote on last edited by
                    #9

                    @F_Mehmood Since they don't use the same concepts, it depends on your usage of the QGraphicsView framework.
                    There's no 1-to-1 porting guide, if you do lots of complex drawing with polygons or curves it will be tricky. If you are using basic shapes and controls it can be simple.

                    QQuickPaintedItem is not hardware accelerated. QQuickRhiItem but more complex, you might not have to use it and could maybe just use existing Items.

                    Do you have a screenshot of your application (or a similar one)? A drawing/description would also do.

                    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