Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to Find a UI By ID at Runtime



  • Couldn't find this question answered, but I have to believe it is a common question:
    Utterly new to Qt and I'm trying to access a UI declared in an QML file at runtime in Android/Java. Someone else created this, I just need a handle to their UI (in Java).

    QML has

    VideoWindow {
        id: player
        anchors.fill: parent
        focus: false
    }

  • Moderators

    I don't think it's possible get a window handle (if that's what you mean) on Android. Qt draws everything into an OpenGL texture on Android - all the system "sees" is a picture.

    There is a way for Qt apps to use Java stuff - through JNI. See QAndroiJniObject maybe it will help. To get some data from QML into Java via JNI, you first will need to pass the data from QML to C++.



  • Hm so for an a/v playing app, would it be fair to say the a/v window (in native Android) should be in a separate activity with Qt drawn over it?


  • Moderators

    @Chris-Weber said in How to Find a UI By ID at Runtime:

    Hm so for an a/v playing app, would it be fair to say the a/v window (in native Android) should be in a separate activity with Qt drawn over it?

    You can play AV in QML using QtMultimedia module.

    Whether it's possible to overlay Qt app on top of another activity - I'm not sure, you'd have to try it out.


Log in to reply