PDA

View Full Version : Posting events to Widgets do different things on Embedded than on Linux



anr78
5th August 2011, 09:17
I'm developing an embedded application, but I also has an x86-build that I use to debug/develop. A recurring issue for me is that posting QKeyEvents to Widgets don't do the same in the two applications.

The current issue:

I use QFileSystemModel and QListView to move around in the filesystem, and based on input from a custom device I have the following code:



QKeyEvent *e = NULL;

if (cmd.down)
e = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, 0, 0);
else if (cmd.up)
e = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, 0, 0);
else if (cmd.ok) {
syslog(LOG_INFO, "press ok, ok?"):
e = new QKeyEvent(QEvent::KeyPress, Qt::Key_Enter, 0, 0);
}

if (e)
QApplication::postEvent(&list, e);

I have also connected a signal to run a function when ok/Enter is pressed:



connect(&list,
SIGNAL(activated(const QModelIndex&)),
this,
SLOT(currentSelected(const QModelIndex&)));

Up/Down works both on embedded and x86, but Key_Enter only gives me the activated-signal on x86. And I wonder why...

anr78
5th August 2011, 11:21
Tried using a QTreeView instead of a QListView, but have the same issue. The activated signal is never emitted on the embedded platform.