Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Can QApplication::style()->standardIcon(...) be used on a QML button? Do 2.0 buttons even support icons?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 2.4k Views
  • 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 Offline
    V Offline
    Violet Giraffe
    wrote on last edited by Violet Giraffe
    #1

    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-worxR 1 Reply Last reply
    0
    • V 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-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @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
      1
      • raven-worxR 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.

        V Offline
        V Offline
        Violet Giraffe
        wrote on last edited by
        #3

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

        jpnurmiJ 1 Reply Last reply
        0
        • V Violet Giraffe

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

          jpnurmiJ Offline
          jpnurmiJ Offline
          jpnurmi
          wrote on last edited by
          #4

          @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
          2
          • jpnurmiJ jpnurmi

            @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 Offline
            V Offline
            Violet Giraffe
            wrote on last edited by
            #5

            @jpnurmi
            Thank you very much!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved