I'm not a OSX user, so I don't know the answer, but what I know is that the getColor method could be done better.
I understand that it's purpose is to grab the (0,0) pixel color from widget, so I don't see why you need to grab the whole desktop ? Can't you use the QWidget::winId()? And if all you need is this one pixel, pass a QRectF(0,0,1,1) to QPixmap::grabWindow, no need to scale anything, so your method will look like:
QRgb getColor
(const QWidget * grabme
){
DEBUG_HIGH_LEVEL << Q_FUNC_INFO;
QRgb result = im.pixel(0,0);
DEBUG_HIGH_LEVEL << "QRgb result =" << hex << result;
return result;
}
QRgb getColor(const QWidget * grabme)
{
DEBUG_HIGH_LEVEL << Q_FUNC_INFO;
QPixmap pix = QPixmap::grabWindow(grabme->winId(),0,0,1,1);
QImage im = pix.toImage();
QRgb result = im.pixel(0,0);
DEBUG_HIGH_LEVEL << "QRgb result =" << hex << result;
return result;
}
To copy to clipboard, switch view to plain text mode
I think it could be faster.
Bookmarks