How to make round imageas
-
I can't seem to find how to make a round Image.
I tried using a mask which didn't workRectangle { id: mask anchors.left: parent.left anchors.leftMargin: 15 width: 50 height: 50 radius:25 clip: true } Image { id: storeIcon anchors.fill: mask source: model.source }Some said to use
ShaderEffectSourcein 2011 but that also didn't work out since qt designer studio couldn't find the import. Am I missing a method? -
@Kiovtorov - take a look at an example directly from Qt; https://doc.qt.io/qt-5/qml-qtgraphicaleffects-opacitymask.html - I think you'll better understand the layout of the code and see what you're missing code wise.
@Markkyboy
The whole problem with OpacityMask wasQtGraphicalEffectssince it is not included in Qt6 but I in a forum I foundimport Qt5Compat.GraphicalEffectsand it now works like following:Rectangle { id: mask anchors.left: parent.left anchors.leftMargin: 15 width: 50 height: 50 radius: 25 clip: true } Image { id: storeIcon anchors.fill: mask source: "qrc:/image.png" fillMode: Image.PreserveAspectCrop layer.enabled: true layer.effect: OpacityMask { maskSource: mask } } -
I can't seem to find how to make a round Image.
I tried using a mask which didn't workRectangle { id: mask anchors.left: parent.left anchors.leftMargin: 15 width: 50 height: 50 radius:25 clip: true } Image { id: storeIcon anchors.fill: mask source: model.source }Some said to use
ShaderEffectSourcein 2011 but that also didn't work out since qt designer studio couldn't find the import. Am I missing a method?@Kiovtorov move the Image inside the scope of
mask. make it a child, not a sibling. -
-
@Kiovtorov - take a look at an example directly from Qt; https://doc.qt.io/qt-5/qml-qtgraphicaleffects-opacitymask.html - I think you'll better understand the layout of the code and see what you're missing code wise.
-
@Kiovtorov - take a look at an example directly from Qt; https://doc.qt.io/qt-5/qml-qtgraphicaleffects-opacitymask.html - I think you'll better understand the layout of the code and see what you're missing code wise.
@Markkyboy
The whole problem with OpacityMask wasQtGraphicalEffectssince it is not included in Qt6 but I in a forum I foundimport Qt5Compat.GraphicalEffectsand it now works like following:Rectangle { id: mask anchors.left: parent.left anchors.leftMargin: 15 width: 50 height: 50 radius: 25 clip: true } Image { id: storeIcon anchors.fill: mask source: "qrc:/image.png" fillMode: Image.PreserveAspectCrop layer.enabled: true layer.effect: OpacityMask { maskSource: mask } } -
K Kiovtorov has marked this topic as solved on