Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
451 views
Welcome To Ask or Share your Answers For Others

1 Answer

In Qt5 winEvent was replaced by nativeEvent:

bool winEvent(MSG* pMsg, long* result)

is now

bool nativeEvent(const QByteArray & eventType, void * message, long *result)

And in EcWin7::winEvent you have to cast void to MSG:

bool EcWin7::winEvent(void * message, long * result)
{
    MSG* msg = reinterpret_cast<MSG*>(message);
    if (msg->message == mTaskbarMessageId)
    {
      ...

I was able to get the application to work! Just replace:

 mWindowId = wid;

with

 mWindowId = (HWND)wid;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...