[Development] WId type changed on Windows

David Faure david.faure at kdab.com
Wed Aug 14 15:33:24 CEST 2013

The combination of b03cabc4cdcc and 66febd27cb in qtbase, broke source compatibility on Windows 32 bit (MSVC).

We now have
   typedef QT_PREPEND_NAMESPACE(quintptr) WId;
while in Qt4, it was
  typedef HWND WId.

This breaks compilation of source code like:
   QMenu *menu = new QMenu(0);
   HWND hWnd = menu->winId(); // error on this line
   SetClassLong(hWnd, GCL_STYLE, GetClassLong(hWnd, GCL_STYLE) & (~CS_DROPSHADOW));

Because WId cannot be casted to a HWND
 (on Windows XP 32 bits, with MSVC 2010).

Is this on purpose, or a side effect of the QPA refactoring and the above-mentionned commits?

I'm wondering because the commit log in b03cabc4cdcc says that the purpose of the
change is exactly that: to be able to cast to HWND. But it was only tested on a 64 bit platform it seems?

Why don't we simply use HWND on Windows again, like in Qt4, and use
whatever is needed on Unix (long? quintptr?) ?

David Faure | david.faure at kdab.com | Managing Director KDAB France
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions

More information about the Development mailing list