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. how can i open the image file (eg. DDS format) all by myself, and then render it as QIcon?
Forum Updated to NodeBB v4.3 + New Features

how can i open the image file (eg. DDS format) all by myself, and then render it as QIcon?

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

    how can i open the image file (eg. DDS format) all by myself, and then render it as QIcon?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ceora
      wrote on last edited by
      #2

      If you use Qt, it support dds format, just get the image path and pass it to QIcon.
      If you are using external lib, the lib loader or some method should return a buffer to the image, take this buffer and pass it to a QImage::loadFromData, then pass QImage to a QIcon.

      1 Reply Last reply
      0
      • O Offline
        O Offline
        opengpu2
        wrote on last edited by
        #3

        i can directly use : QIcon icon(filePath);
        can i use QPixmapCache then to optimize ?

        is this better?
        QPixmap pixmap(filePath);
        QIcon icon = QIcon(pixmap);

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ceora
          wrote on last edited by
          #4

          It depend on what you have to do: the documentation give you all the different flavor of each class.

          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