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. [SOLVED]QML standard icons
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]QML standard icons

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 5.4k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    steno
    wrote on last edited by
    #1

    I'm looking to get some of the OS's standard images within QML, and want to know if there is a way to do this. The only way I can see how to do it is to derive off of QQuickImageProvider and provided the needed pixmap. Is there a simpler way?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vincent007
      wrote on last edited by
      #2

      Can you get the path of your images wanted? If yes, you can use path to set source of Image.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        steno
        wrote on last edited by
        #3

        I'm trying to get the standard pixmaps from QStyle, and I don't believe those have an associated path for them. I did something like this and it works, but if there was an easier way I would like to do it.

        @
        QPixmap ZStandardImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
        {
        if(mWidgetOfInterest.isNull())
        return QPixmap(requestedSize);

        QIcon icon;
        if(id == DNTs("SP_MessageBoxWarning"))
        {
             icon = mWidgetOfInterest->style()->standardIcon(QStyle::SP_MessageBoxWarning);
        }
        
        if(icon.isNull())
            return QPixmap(requestedSize);
        
        return icon.pixmap(requestedSize);
        

        }
        @

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jens
          wrote on last edited by
          #4

          No I am afraid those icons are not directly exposed to qml so the suggested workaround is probably ok.

          We do have support for iconNames on some controls though. I.e you can set iconName instead of iconSource to use bundled or system-specific themes, but that is not what you are looking for here.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            steno
            wrote on last edited by
            #5

            Sweet, thanks to both.

            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