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. Does widget painting allow for blending?
Forum Update on Monday, May 27th 2025

Does widget painting allow for blending?

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 2.4k 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.
  • P Offline
    P Offline
    primem0ver
    wrote on last edited by
    #1

    I am creating a test program that is designed to be used to create a complex algorithm to calculate values based on several points of data for a map. The "Map" is a Qt Widget. Plots on the map will have a consistent shape but may be any one of a number of shapes, depending on the type of map (hexes or squares for example).

    I need to be able to use different blending techniques so that the resulting map can illustrate multiple data sets at once and color/shade/texture each plot accordingly. Some example techniques would be subtraction, addition, logical and, logical or, etc...

    I know that if I were to draw the widget one plot at a time using simple color blending, this would be relatively easy. However, it would really help the complexity of adding new data layers if I could draw each data layer (all plots) one at a time and blend the individual layers together to get the final result. If possible I would like to use/draw/blend textures as well

    Does Qt's widget drawing library allow for this kind of functionality? Currently I would need to draw filled polygons and squares.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! AFAIK Qt doesn't provide anything for that. Of course you can implement this by yourself with QPainter but I'd strongly recommend to use OpenGL for this as it sounds like rendering performance could become an issue.

      P 1 Reply Last reply
      0
      • ? A Former User

        Hi! AFAIK Qt doesn't provide anything for that. Of course you can implement this by yourself with QPainter but I'd strongly recommend to use OpenGL for this as it sounds like rendering performance could become an issue.

        P Offline
        P Offline
        primem0ver
        wrote on last edited by
        #3

        @Wieland OpenGL shouldn't be necessary. .NET handled an early version of this just fine without using a 3D API (though I didn't use textures in that one). The reason for the platform switch is because I need to do it in C++ anyway and I am making a version that handles multiple types of maps.

        So there isn't any way to blend images together either? After posting this I thought I might be able to do it by painting to a couple of devices and then blending the bitmaps themselves together.

        kshegunovK 1 Reply Last reply
        0
        • P primem0ver

          @Wieland OpenGL shouldn't be necessary. .NET handled an early version of this just fine without using a 3D API (though I didn't use textures in that one). The reason for the platform switch is because I need to do it in C++ anyway and I am making a version that handles multiple types of maps.

          So there isn't any way to blend images together either? After posting this I thought I might be able to do it by painting to a couple of devices and then blending the bitmaps themselves together.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @primem0ver
          http://doc.qt.io/qt-5/qpainter.html#composition-modes
          Is this blending?

          Read and abide by the Qt Code of Conduct

          ? 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @primem0ver
            http://doc.qt.io/qt-5/qpainter.html#composition-modes
            Is this blending?

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by A Former User
            #5

            @kshegunov Didn't know these composition modes exist. Interesting!

            kshegunovK 1 Reply Last reply
            0
            • ? A Former User

              @kshegunov Didn't know these composition modes exist. Interesting!

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by kshegunov
              #6

              @Wieland
              Really? I find that hard to believe. They're pretty old (by old I mean they exist from Qt 4.x, where x is very small). :)

              Read and abide by the Qt Code of Conduct

              ? 1 Reply Last reply
              0
              • kshegunovK kshegunov

                @Wieland
                Really? I find that hard to believe. They're pretty old (by old I mean they exist from Qt 4.x, where x is very small). :)

                ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                @kshegunov You live and learn. ;-)

                kshegunovK 1 Reply Last reply
                0
                • ? A Former User

                  @kshegunov You live and learn. ;-)

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by kshegunov
                  #8

                  @Wieland

                  You live and learn. ;-)

                  Indeed.

                  They, of course, can trivially be outperformed by dedicated hardware (as with OpenGL) and all of them are supported only for QImage, but well you can't have everything in life ... :)

                  It would be interesting to test how that QPainter blending fares over the OpenGL engine, though. It might just work out of the box. :)

                  Read and abide by the Qt Code of Conduct

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

                    Hi,

                    To add to my fellows you might be interested by the Image Composition example that looks a bit like a first step for what you would like to achieve.

                    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
                    0
                    • P Offline
                      P Offline
                      primem0ver
                      wrote on last edited by primem0ver
                      #10

                      Yes! That should do it. Thank you very much.

                      EDIT: SGaist, thanks for that bit as well.

                      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