Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How do I access / load icon in QtCreator ? From "theme path" to " theme name "?
Forum Updated to NodeBB v4.3 + New Features

How do I access / load icon in QtCreator ? From "theme path" to " theme name "?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 2 Posters 772 Views 2 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    Here is my sample code to access "New" icon.

    const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/images/new.png"));

    I am looking for basic bluetooth icon.
    I know it exists in my system as "bluetooth.png".

    I can retrieve "theme" path

      qDebug() << QIcon::themeSearchPaths();
    

    How do I get form "theme path" to " theme name "?
    Or do I have to ?

    QIcon RTFM is not much help.

    THANKS

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Freedesktop specification does not specify any icons for Bluetooth. So getting one through fromTheme() will not work.

      Looking through KDE code for bluedevil, I noticed these:

          if (deviceConnected) {
              return "preferences-system-bluetooth-activated";
          } else if (!btManager.bluetoothOperational) {
              return "preferences-system-bluetooth-inactive";
          }
          return "preferences-system-bluetooth";
      

      Source: https://github.com/KDE/bluedevil/blob/master/src/applet/package/contents/ui/logic.js

      I have no idea if it will work, but it might be worth a try.

      (Z(:^

      A 1 Reply Last reply
      2
      • sierdzioS sierdzio

        Freedesktop specification does not specify any icons for Bluetooth. So getting one through fromTheme() will not work.

        Looking through KDE code for bluedevil, I noticed these:

            if (deviceConnected) {
                return "preferences-system-bluetooth-activated";
            } else if (!btManager.bluetoothOperational) {
                return "preferences-system-bluetooth-inactive";
            }
            return "preferences-system-bluetooth";
        

        Source: https://github.com/KDE/bluedevil/blob/master/src/applet/package/contents/ui/logic.js

        I have no idea if it will work, but it might be worth a try.

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @sierdzio Thanks.
        It looks as I could do this the "create your own icon" way so I can reuse existing QIcon code.

        I found few python code examples

        Basically use any "bluetooth.png" icon currently on my system.

        Still looking for some explanation why I need "theme".
        It looks as they are using "theme" as some kind of "chapter"... or directory.

        Basically - if I am looking for an icon to represent a "bullet train" - how do I correlate that to "theme"?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          I don't understand the why you mention theme name at all, sorry. "fromTheme" simply means "give me an icon from system theme" or "give me a standard system icon". The method returns an icon (ready to use), not path - there is no need to convert icon to theme or anything like that. Or I'm missing your point.

          (Z(:^

          1 Reply Last reply
          1

          • Login

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