Qt 5 widgets bug? Mouse tracking doesn't work with OpenGL widget on Mac OS
-
I'm trying to enable mouse tracking for my GL view. It seems to work right from the start, but as I try clicking in the window and moving the cursor in and out, GL widget starts receiving mouse events erratically. Tried on two different Macs with different Macs (10.7 and 10.8).
"This is the link to a simple test project":http://rghost.ru/download/43893939/c54664b180cc40ed39d91337e41934b2ea35b20f/test.zip illustrating the issue. Mouse events are being logged with qDebug, you should be able to easily tell whether tracking works fine or not by moving and clicking your mouse and looking at the output. I'd appreciate if someone could look at the project and conclude whether this is my error or Qt 5 bug. I seriously suspect the latter.
P. S. The same code works like charm with Qt 4.8, also works on Windows with Qt 5.
-
I also experienced very weird mouse tracking behaviour in a custom GL view (mac; untested on windows and linux). So much so that I had to downgrade to 4.8 in which everything works beautifully. Really hope it can be fixed soon.
-
Same, will have to downgrade... I'd like to find out it's a bug in my code that I can fix, but wasn't able to find any errors on my part (perhaps, someone could verify the test project I've attached?).
I've reported a bug, no reply so far: https://bugreports.qt-project.org/browse/QTBUG-29751 -
Might be helpful if you uploaded the raw source files somewhere; e.g. on pastebin rather than packaging up in a zip (just a security concern)
-
It's a bunch of files. I don't see any other sensible way to upload them.
-
Will have a look when I'm home -- I'm at work right now and would prefer not to download a zip file from a file sharing website that I know nothing about.
Cheers,
Ben. -
The bug has been approved and assigned, case closed, I guess.
-
For anyone like me having the problem, if you cannot wait for Qt 5.1 here's the workaround I've done (for QGLWidget):
1/ in your QMainWindow initialization, add:
@setMouseTracking(true);@
2/ in your QMainWindow header, add:
@protected:
void mouseMoveEvent(QMouseEvent *event);@
3/ in your QMainWindow source, add:
@void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
QWidget *child=childAt(event->pos());
QGLWidget *glwidget = qobject_cast<QGLWidget *>(child);
if(glwidget) {
QMouseEvent *glevent=new QMouseEvent(event->type(),glwidget->mapFromGlobal(event->globalPos()),event->button(),event->buttons(),event->modifiers());
QCoreApplication::postEvent(glwidget,glevent);
}
}@ -
I found that it want not work with QQuickItem, too.