Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QIcon name() is empty, can we set it on creation?

QIcon name() is empty, can we set it on creation?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 596 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.
  • C Offline
    C Offline
    Calicoder
    wrote on last edited by
    #1

    Good day QT'ers, been looking for a way to grab a QIcon name but it's always returning as "".

    QIcon pushON;
    pushOn.addFile(":/img/on.png");
    qDebug.log << pushOn.name()    <-- returns as ""
    

    Is this a bug in QIcon? Can we set the name when creating the icon?

    Thanks and much appreciated.

    Christian EhrlicherC 1 Reply Last reply
    0
    • C Calicoder

      Good day QT'ers, been looking for a way to grab a QIcon name but it's always returning as "".

      QIcon pushON;
      pushOn.addFile(":/img/on.png");
      qDebug.log << pushOn.name()    <-- returns as ""
      

      Is this a bug in QIcon? Can we set the name when creating the icon?

      Thanks and much appreciated.

      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      @Calicoder said in QIcon name() is empty, can we set it on creation?:

      Is this a bug in QIcon?

      No, please read the docs:

      Returns the name used to create the icon, if available.
      Depending on the way the icon was created, it may have an associated name. This is the case for icons created with fromTheme() or icons using a QIconEngine which supports the QIconEngine::IconNameHook.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      C 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        @Calicoder said in QIcon name() is empty, can we set it on creation?:

        Is this a bug in QIcon?

        No, please read the docs:

        Returns the name used to create the icon, if available.
        Depending on the way the icon was created, it may have an associated name. This is the case for icons created with fromTheme() or icons using a QIconEngine which supports the QIconEngine::IconNameHook.

        C Offline
        C Offline
        Calicoder
        wrote on last edited by
        #3

        @Christian-Ehrlicher So I should create the icons with a theme for the name() to work?

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Since QIcon::fromTheme() needs a icon name, QIcon::name() will return it.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          C 1 Reply Last reply
          2
          • Christian EhrlicherC Christian Ehrlicher

            Since QIcon::fromTheme() needs a icon name, QIcon::name() will return it.

            C Offline
            C Offline
            Calicoder
            wrote on last edited by
            #5

            @Christian-Ehrlicher Perfect, thanks so 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