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:

Qt Code:
  1. QKeyEvent *e = NULL;
  2.  
  3. if (cmd.down)
  4. e = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, 0, 0);
  5. else if (cmd.up)
  6. e = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, 0, 0);
  7. else if (cmd.ok) {
  8. syslog(LOG_INFO, "press ok, ok?"):
  9. e = new QKeyEvent(QEvent::KeyPress, Qt::Key_Enter, 0, 0);
  10. }
  11.  
  12. if (e)
  13. 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:

Qt Code:
  1. connect(&list,
  2. SIGNAL(activated(const QModelIndex&)),
  3. this,
  4. 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...