Triggering Qt custom context menu in android

  • 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)
        connect(ui->lcdNumber , SIGNAL(customContextMenuRequested(const QPoint &)) \
                , this , SLOT(showContextMenu(const QPoint &)));
    void MainWindow::showContextMenu(const QPoint& 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()));

    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 QMetaObject::invokeMethod: No such method QQuickRootItem::inputMethodQuery(Qt::InputMethodQuery,QVariant)

    How can I achieve that?