QT版本:5.14.3
在CMakeLists.txt里添加模块:winextras
涉及的lib:Qt5WinExtras.lib
find_package(
Qt5
Core
Gui
Widgets
winextras
)
target_link_libraries(
Qt5::Svg
Qt5::Widgets
Qt5::WinExtras
${QTSINGLEAPPLICATION_LIBRARY}
)
调用方式:
#include <QtWinExtras> // 注意不是#include <QtWin>
//函数原型
//QPixmap QtWin::fromHBITMAP(HBITMAP bitmap, QtWin::HBitmapFormat format = HBitmapNoAlpha)
//调用
HBITMAP bitmap = CreateBitmap(); //待转换的HBITMAP
QPixmap p = QtWin::fromHBITMAP(bitmap, HBitmapNoAlpha); //QtWin为命名空间