Events received by main window

Post questions, comments and feedback to our 3Dconnexion UNIX and Linux Development Team.

Moderator: Moderators

Post Reply
spacenavdev
Posts: 4
Joined: Mon Aug 13, 2007 1:23 pm

Events received by main window

Post by spacenavdev » Mon Aug 13, 2007 1:45 pm

I have created a simple test application using Qt to test the SpaceNavigator. I have a main window that contains 2 widgets.

Upon receiving a QEvent::Enter, I call MagellanSetWindow with the second widget's window id.

Upon receiving a QEvent::Leave, I call MagellanSetWindow with InputFocus.

However, when my application receives the Magellan events, it always sends them to my application's main window, not to the second widget.

Is this the correct behaviour?

crobl
Moderator
Moderator
Posts: 131
Joined: Mon Feb 26, 2007 8:34 am
Location: Freiham, Germany

Post by crobl » Wed Aug 22, 2007 9:58 am

Hi spacenavdev,

I'm not very familiar with Qt, so please correct me if I'm wrong.
From what I've read QMainWindow (inherits QWidget) and QWidget both can receive/generate QEvents.

So if you enter (QEvent::Enter) your window you set the 2nd-QWidget's window id (QMainWindow?), which is now the receiver of the Magellan events.
If you now move (within the QMainWindow) to one of the both contained QWidgets the same thing happens again, correct?
In both cases your QMainWindow is/should be the receiver, which is just perfect.

If you leave one of the two QWidgets (QEvent::Leave) you call MagellanSetWindow() with InputFocus, which is still your QMainWindow since you're still within the window. So that behaviour is correct.

If you further leave your QMainWindow (again QEvent::Leave) and thus call MagellanSetWindow() with InputFocus again, the events should not be sent to your QMainWindow any longer, but to the window that has the new InputFocus.

Hope I could help!


Christian Robl
3Dconnexion

spacenavdev
Posts: 4
Joined: Mon Aug 13, 2007 1:23 pm

Post by spacenavdev » Fri Aug 24, 2007 9:55 am

I was expecting the events to be sent to the 2nd QWidget itself (as I was sending the QWidget's own id to MagellanSetWindow), not the containing QMainWindow. In other words, I was expecting it to work the same way as for normal keyboard or mouse events, which are sent directly to the 2nd QWidget itself.

However, it seems that the events are sent to the containing window, not the widget, so I have come up with a workaround.

crobl
Moderator
Moderator
Posts: 131
Joined: Mon Feb 26, 2007 8:34 am
Location: Freiham, Germany

Post by crobl » Mon Aug 27, 2007 9:33 am

Hi spacenavdev,

maybe its because our events are XClientMessages and Qt processes them this way. :?

Anyway. I think a workaround (propagate certain QEvents down to a child ) isn't that difficult in Qt, is it?


Good luck!


Christian Robl
3Dconnexion

Post Reply