QAction shortcuts in QML
-
I have an application that has QQuickView set as the central widget of QMainWindow through a proxy class QWindowContainer (lost where I found this class). This all seems to work, except QAction shortcuts, if the focus is on QQuickView. For instances I want to be able to hit F5 to do a refresh in my application. I have this bound up:
@ _refreshPresentationAction = new QAction(QIcon(":/refresh.png"), tr("&Refresh"), this);
_refreshPresentationAction->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::Key_F5));
_refreshPresentationAction->setStatusTip(tr("Refresh the presentation"));
connect(_refreshPresentationAction, SIGNAL(triggered()), this, SLOT(_refreshPresentation()));@If the focus is on QMainWindow then it works, but if the focus is in my customised QQuickItem nothing happens. I've overrided keyPressEvent and do get the F5 keyEvent coming through, but I don't know where to send it from there?
Cheers for any help
-
I'm also interested in this. I have a class which derives from QQuickView and I'm trying to use a simple QAction in it like this
@
Client::Client(QWindow* parent) : QQuickView(parent)
{
//[...]
quitAction = new QAction(this);
quitAction->setShortcut(QKeySequence(Qt::Key_F5));connect(quitAction, SIGNAL(triggered()), this, SLOT(close())); //[...]
}
@However, the QQuickView doesn't seem to react when I press F5. I'd be happy to post more code if needed. Any help greatly appreciated!