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



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



  • 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.



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

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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.