<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<font face="Courier New, Courier, monospace"><font color="#ffffff">Hello,<br>
<br>
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:<br>
<br>
buttontest.py:<br>
import sys<br>
<br>
from PyQt6.QtGui import QGuiApplication<br>
from PyQt6.QtQml import QQmlApplicationEngine<br>
<br>
if __name__=="__main__":<br>
<br>
app = QGuiApplication(sys.argv)<br>
engine = QQmlApplicationEngine()<br>
engine.quit.connect(app.quit)<br>
engine.load('buttontest.qml')<br>
<br>
sys.exit(app.exec())<br>
<br>
<br>
buttontest.qml:<br>
<span style="font-style: italic;">import</span> QtQuick
<br>
<span style="font-style: italic;">import</span> QtQuick.Controls
2.15<br>
<br>
<span style="font-style: italic;">import</span>
QtQuick.Controls.Material 2.15<br>
<br>
ApplicationWindow {<br>
visible: true<br>
width: 400<br>
height: 200<br>
title: "Button Test"<br>
Material.theme: Material.Dark<br>
color: "#111111"<br>
<br>
ScreenA {<br>
id: <span style="font-style: italic;">screenA</span><br>
}<br>
}<br>
<br>
ScreenA.qml:<br>
<span style="font-style: italic;">import</span> QtQuick
<span style="font-style: italic;">import</span> QtQuick.Controls
2.15
<span style="font-style: italic;">import</span>
QtQuick.Controls.Material 2.15
<br>
Rectangle {<br>
id: <span style="font-style: italic;">rectangle</span><br>
width: 400<br>
height: 200<br>
color: "#000000"<br>
border.color: "#000000"
<br>
<br>
Image {<br>
id: <span style="font-style: italic;">btni<br>
</span> source: "./icon-arrow-down-red.png"<br>
}
<br>
<br>
Button {<br>
id: <span style="font-style: italic;">button</span><br>
x: 200<br>
y: 100<br>
width: 48<br>
height: 48<br>
visible: true<br>
display: Button.IconOnly<br>
icon.source: "./icon-arrow-down-red.png"<br>
icon.color: "transparent"<br>
text: "Text"
}
<br>
}
</font><br>
<br>
The Image works well, the Button not.<br>
<br>
<br>
Am I doing something wrong?<br>
<br>
<br>
</font>
</body>
</html>