Qt Forum

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

    Solved Does widget painting allow for blending?

    General and Desktop
    4
    10
    1884
    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.
    • P
      primem0ver last edited by

      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 Reply Quote 0
      • ?
        A Former User last edited by

        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 Reply Quote 0
        • P
          primem0ver @Guest last edited by

          @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.

          kshegunov 1 Reply Last reply Reply Quote 0
          • kshegunov
            kshegunov Moderators @primem0ver last edited by

            @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 Reply Quote 0
            • ?
              A Former User @kshegunov last edited by A Former User

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

              kshegunov 1 Reply Last reply Reply Quote 0
              • kshegunov
                kshegunov Moderators @Guest last edited by 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). :)

                Read and abide by the Qt Code of Conduct

                ? 1 Reply Last reply Reply Quote 0
                • ?
                  A Former User @kshegunov last edited by

                  @kshegunov You live and learn. ;-)

                  kshegunov 1 Reply Last reply Reply Quote 0
                  • kshegunov
                    kshegunov Moderators @Guest last edited by kshegunov

                    @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 Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      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 Reply Quote 0
                      • P
                        primem0ver last edited by primem0ver

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

                        EDIT: SGaist, thanks for that bit as well.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post