qt 浏览器的winid,在Windows上使用Qt5(从WId)获取HWND

在将Qt4应用迁移至Qt5的过程中,遇到如何获取QWidget在Windows上的HWND的问题。Qt4中,WId是HWND的typedef,但在Qt5中不再如此。通过分析发现,可以使用Qt5的nativeEvent替代winEvent,并通过reinterpret_cast将winId转换为HWND,从而解决EcWin7库在任务栏图标显示进度的需求。
摘要由CSDN通过智能技术生成

I am trying to convert a Qt4 Application to Qt5.

The only thing I couldn't figure out is how to get the HWND of a Widget.

The program uses EcWin7 to show the progress on the taskbar icon on win 7+ but expects a HWND. The lib itself seems to compile fine after changing *Q_WS_WIN* to *Q_OS_WIN*)

In Qt4 on Windows WId was just a typedef for HWND, so this was no problem.

In Qt5 this is not the case anymore.

I found some mailing list posting that could give a clue but it seems QPlatformNativeInterface is not part of the public API of Qt5 anymore.

The program calls EcWin7.init(this->winId()); and I need to some way to convert this ID into the HWND id or some other way to get this.

解决方案

In Qt5 winEvent was replaced by nativeEvent:

bool winEvent(MSG* pMsg, long* result)

is now

bool nativeEvent(const QByteA

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值