2

I currently have a windows API that requires a HWND hParentWnd. My question is how can I obtain HWND of a class derived from QMainWindow ?

mihai
  • 4,592
  • 3
  • 29
  • 42
Rajeshwar
  • 11,179
  • 26
  • 86
  • 158
  • 2
    Similar question: [Get HWND on windows with Qt5 (from WId)](http://stackoverflow.com/questions/14048565/get-hwnd-on-windows-with-qt5-from-wid) – Ilya Nov 14 '13 at 06:30

1 Answers1

2

You can use QWidget::effectiveWinId() or QWidget::winId(), this holds the HWND of the widget on Windows.

MainWindow w;
w.show();
HWND hWnd = (HWND) w.winId();
DrummerB
  • 39,814
  • 12
  • 105
  • 142
sashoalm
  • 75,001
  • 122
  • 434
  • 781