Does widget painting allow for blending?



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



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



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


  • Qt Champions 2016



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


  • Qt Champions 2016

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



  • @kshegunov You live and learn. ;-)


  • Qt Champions 2016

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


  • Lifetime Qt Champion

    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.



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

    EDIT: SGaist, thanks for that bit as well.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.