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:
if (cmd.down)
else if (cmd.up)
else if (cmd.ok) {
syslog(LOG_INFO, "press ok, ok?"):
}
if (e)
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);
To copy to clipboard, switch view to plain text mode
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&)));
connect(&list,
SIGNAL(activated(const QModelIndex&)),
this,
SLOT(currentSelected(const QModelIndex&)));
To copy to clipboard, switch view to plain text mode
Up/Down works both on embedded and x86, but Key_Enter only gives me the activated-signal on x86. And I wonder why...
Bookmarks