-
Bug
-
Resolution: Cannot Reproduce
-
P2: Important
-
4.8.4, 5.0.2
-
OSX 10.8
The following snippet creates small window painted with the pixel color under the mouse. Click and drag in the widget and then position the mouse over any item on the desktop.
On a Windows 7 system with two monitors, this works on both the primary and secondary monitor.
On Mac OSX 10.8, it only works on the primary monitor. On the secondary display, the color returned is black.
#include <QtGui> class Widget : public QWidget { public: Widget(QWidget *parent = 0) : QWidget(parent) { resize(100, 100); } void paintEvent(QPaintEvent *) { QPainter p(this); p.fillRect(rect(), m_color); } void mouseMoveEvent(QMouseEvent *evt) { m_color = ColorUnderPos(QCursor::pos()); update(); } QColor ColorUnderPos(const QPoint &globalPt) { QColor color; const int screenNo = qApp->desktop()->screenNumber(globalPt); QWidget *desktopWidget = qApp->desktop()->screen(screenNo); const QImage screen = QPixmap::grabWindow( desktopWidget->winId(), globalPt.x(), globalPt.y(), 1, 1).toImage(); const QRgb c = screen.pixel(QPoint(0, 0)); color.setRgb(qRed(c), qGreen(c), qBlue(c)); return color; } QColor m_color; }; int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); }
| For Gerrit Dashboard: QTBUG-30284 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 53497,1 | Fixed a bug where screenshot taken from secondary monitor was "empty" | release | qt/qtbase | Status: ABANDONED | 0 | 0 |
| 53503,1 | Fixed a bug where screenshot taken from secondary monitor was "empty" | stable | qt/qtbase | Status: ABANDONED | 0 | 0 |