Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt 6 replacement for ColorOverlay?



  • Is there a Qt 6 replacement for ColorOverlay?

    I'm upgrading from Qt 5.15 to 6.1. Most of my images are SVG using the ColorOverlay from QtGraphicalEffects. I see that I can use Qt5Compat.GraphicalEffects, but I'm not clear if that is the long term solution or if there is some other way I should be doing color overlay on images in Qt 6.

    This app will only be in Qt 6, so I don't need backwards compatibility to 5.15.

    Thanks!
    -chris



  • @christofer Side note...

    I was getting console messages like this...

    Texture 0x71f12c0f14440 () used with different accesses within the same pass, this is not allowed.
    

    The messages stop if I cache each ColorOverlay. This isn't a problem, as far as I can tell, because none of my images are animated. But I don't know if it's expected.

    Example that doesn't get the message...

    Image {
       source: "/images/my-image.svg"
       width: 30
       height: 30
       ColorOverlay {
          color: "#99FF99"
          anchors.fill: parent
          source: parent
          cached: true
       }
    }
    

    Example that does get the message...

    Image {
       source: "/images/my-image.svg"
       width: 30
       height: 30
       ColorOverlay {
          color: "#99FF99"
          anchors.fill: parent
          source: parent
          //cached: true
       }
    }
    


  • The example in the documentation shows the ColorOverlay as a sibling of the Image, with the Image's visible set to false. Perhaps putting a ColorOverlay inside an Image results in one of them being traversed twice.



  • @jeremy_k Thanks Jeremy! Making ColorOverlay a sibling works without having to cache.

    I'm leaving the thread "unresolved" because my original question is about whether we should be using something other that qt5compat with Qt6 for the long run.

    Example that works without cache...

    Image {
       id: theImage
       source: "/images/my-image.svg"
       width: 30
       height: 30
    }
    ColorOverlay {
       color: "#99FF99"
       anchors.fill: theImage
       source: theImage
    }
    

    update: Using ColorOverlay as sibling worked everywhere except in a Row. The layout of the Row got collapsed. cached: true works for my particular case in the Row but it still seems buggy.



  • @christofer said in Qt 6 replacement for ColorOverlay?:

    whether we should be using something other that qt5compat with Qt6 for the long run.

    https://bugreports.qt.io/browse/QTBUG-85256
    https://bugreports.qt.io/browse/QTBUG-78572

    ColorOverlay was ported so you can use the BSD licensed repo in Qt6


Log in to reply