Can QApplication::style()->standardIcon(...) be used on a QML button? Do 2.0 buttons even support icons?
-
I use icons like
QApplication::style()->standardIcon(QStyle::SP_MediaSeekForward)
in my Windgets application that I'm now porting to QML. Can I use these icons there as well? It sure saves me a lot of headache not having to bundle my own icons.
I could create a C++ icon provider class that would fetch the icon and returnQIcon
orQPixmap
, but I don't see a way to assign it to a button.In fact, with Qt Quick Controls 2.0 I don't see ANY way to assign an icon to a button. Is there 2.0 controls documentation? I can't find any, only 1.4 where you have
iconSource
andiconName
. -
@Violet-Giraffe
you can simply create your custom QQuickImageProvider to do so
Map the names to the QStyle::StandardPixmap enum and convert the QIcon to a QPixmap/QImage. -
@raven-worx
Thank you, that's great!
But 2.0Button
doesn't support icons anymore, and neither does any of its subclasses unless I missed something. Is there a button-like component that can have an icon? -
@Violet-Giraffe said:
But 2.0
Button
doesn't support icons anymore, and neither does any of its subclasses unless I missed something.I'm afraid we are not going to rush with icon support for Qt Quick Controls 2 before Qt Quick's high-DPI icon support in general has been sorted out: https://bugreports.qt.io/browse/QTBUG-49820
Is there a button-like component that can have an icon?
For now, you can change the
contentItem
to anImage
: http://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/examples/quickcontrols2/gallery/gallery.qml#n67