Search code examples
qtqwidget

Qt exposes a QWidget's handle with getDC - how do I get a QWidget's handle on the Mac?


I can make native win32 calls (GetPixel/SetPixel) on a QWidget by using QWidget::getDC .. How do I do this for Mac builds?

Using QImage/QPixmap for retrieving pixel information is not an option because I need very fast access to what's already been drawn onto a QWidget via QPainter on both Windows and Mac.

The reason I am using GetPixel on windows is to implement 2d mouse picking.


Solution

  • I am not sure what you are trying to do but if you want the underlying window system handle/ID, you can use QWidget::winId() which returns HIViewRef or NSView on Mac depending on if it's Carbon or Cocoa version of Qt library.