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. Problem with QIcon::fromTheme()
Forum Updated to NodeBB v4.3 + New Features

Problem with QIcon::fromTheme()

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.6k 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.
  • R Offline
    R Offline
    RazrFalcon
    wrote on last edited by
    #1

    from docs:
    "Or if you want to provide a guaranteed fallback for platforms that do not support theme icons, you can use the second argument:" @QIcon undoicon = QIcon::fromTheme("edit-undo", QIcon(":/undo.png"));@ so on Windows will be used only fallback icons, right?
    But if I use such code in my .pro file:
    @win32:RESOURCES += icons.qrc@
    I get such errors on Linux:
    @Cannot open file ':/undo.png', because: Unknown error@

    How to tell Qt use system icons on linux and icons from resource on Windows?
    Thanks.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Did you actually put an undo.png into the resource file? And is it accessible via that path? Can you show the contents of icons.qrc, please.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RazrFalcon
        wrote on last edited by
        #3

        Of course all icons presents in resource file.
        But if I'm on Linux - I do not want to compile resource into binary, I want to use system icons only.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Ah, sorry, I misread the first post. The default icon must be provided as a ready-to-use icon. So, if you do not provide the resource file on Linux, the icon cannot be created - hence the error message. So you would either need to #ifdef the code and leave out the default for Linux or add your default set of icons to the resource file on Linux too. I would go for the latter, as I would not bet that in any and every case you'll have system icons on Linux too, so providing your default set is a good idea. The additional size is negligible, in my opinion.

          http://www.catb.org/~esr/faqs/smart-questions.html

          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