QPixmap::toWinHICON() in Qt5
Long story short, here’s a workaround to a common gripe, missing QPixmap::toWinHICON() in Qt5.
#if QT_VERSION >= 0x050000 extern HICON qt_pixmapToWinHICON(const QPixmap &p); #else #define qt_pixmapToWinHICON(p) p.toWinHICON() #endif HICON hIcon = qt_pixmapToWinHICON(QPixmap("test.png"));
References:
November 14th, 2012 at 02:05
Is it not missing Q_GUI_EXPORT ?
November 14th, 2012 at 02:27
You’re the C++ wizard so you tell me. 🙂 I thought it wasn’t necessary for an external function declaration. This piece of code links fine with MSVC2010 at least, but I haven’t tried other compilers.