icon.source property not working in QML Button?

Yuya Nishihara yuya at tcha.org
Tue May 3 03:27:46 BST 2022


On Mon, 2 May 2022 23:26:15 +0200, Belz Ulrich wrote:
> It looks like the icon.source property of a QML Button is not working 
> (PyQt 6.2.2). The referenced image is not shown. Example to reproduce:

>    Button {
>      id: button
>      x: 200
>      y: 100
>      width: 48
>      height: 48
>      visible: true
>      display: Button.IconOnly
>      icon.source: "./icon-arrow-down-red.png"

Basically you need to wrap relative paths with Qt.resolvedUrl() in Qt 6.

There's a significant behavior change regarding relative path (or URL)
resolution, and icon.source is broken until Qt 6.2.5.

https://doc.qt.io/qt-6/qml-changes-qt6.html#url-resolution
https://bugreports.qt.io/browse/QTBUG-95587


More information about the PyQt mailing list