Triggering Qt custom context menu in android
Unsolved
Mobile and Embedded
-
Hello everybody.I'm trying to get started with android development using Qt and now I want to create a custom context menu for android in C++.
What I've done so far is as follows:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); ui->lcdNumber->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->lcdNumber , SIGNAL(customContextMenuRequested(const QPoint &)) \ , this , SLOT(showContextMenu(const QPoint &))); } void MainWindow::showContextMenu(const QPoint& point) { Q_UNUSED(point); //To open up the menu in the cursor position instead of the widget's top-left point QPoint mousePos = QCursor::pos(); QMenu *cMenu = new QMenu(tr("Sample Context Menu")); QAction closeAction("Close" , this); QAction yetAnotherAction("Yet another action" , this); QObject::connect(&closeAction , SIGNAL(triggered()) , this , SLOT(close())); cMenu->addAction(&yetAnotherAction); cMenu->addAction(&closeAction); cMenu->exec(mousePos); }
This is just a demo. It works well in desktop when I right-click the widget lcdNumber but in android I'm not able to open up the menu by long-clicking(i.e touching and holding) it.
Also the example mentioned here using QtQuick doesn't work for me and results in this error:
LOGCAT: W libmenuDemo-qtquick_armeabi-v7a.so: QMetaObject::invokeMethod: No such method QQuickRootItem::inputMethodQuery(Qt::InputMethodQuery,QVariant)
How can I achieve that?