Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Can QApplication::style()->standardIcon(...) be used on a QML button? Do 2.0 buttons even support icons?

    QML and Qt Quick
    3
    5
    1944
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      Violet Giraffe last edited by Violet Giraffe

      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 return QIcon or QPixmap, 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 and iconName.

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @Violet Giraffe last edited by raven-worx

        @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.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        V 1 Reply Last reply Reply Quote 1
        • V
          Violet Giraffe @raven-worx last edited by

          @raven-worx
          Thank you, that's great!
          But 2.0 Button 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?

          jpnurmi 1 Reply Last reply Reply Quote 0
          • jpnurmi
            jpnurmi @Violet Giraffe last edited by

            @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 an Image: http://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/examples/quickcontrols2/gallery/gallery.qml#n67

            V 1 Reply Last reply Reply Quote 2
            • V
              Violet Giraffe @jpnurmi last edited by

              @jpnurmi
              Thank you very much!

              1 Reply Last reply Reply Quote 0
              • First post
                Last post