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. [solved]How to check absence of icon in the resources
Forum Update on Monday, May 27th 2025

[solved]How to check absence of icon in the resources

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 6.5k 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.
  • H Offline
    H Offline
    Hostel
    wrote on last edited by
    #1

    I have problem with checking icon from resource. Code for example:
    @
    QIcon myIcon( ":/wrong/path/to/icon" )
    myIcon.isNull() // return false but there is no icon
    @

    How can I checked that icon is present in resources?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      bq. "bool QIcon::isNull() const":http://qt-project.org/doc/qt-5.0/qicon.html#isNull
      Returns true if the icon is empty; otherwise returns false.
      An icon is empty if it has neither a pixmap nor a filename.
      Note: Even a non-null icon might not be able to create valid pixmaps, eg. if the file does not exist or cannot be read.

      Use QFile::exists() instead.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hostel
        wrote on last edited by
        #3

        Thanx QFile::exists() is what I need.

        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