How to open a new window in Android?



  • Hi,

    I'm trying to show a new window after clicking in the menu. I'm creating the windows as a new component. Something like this:

    @
    onTriggered: {

                    var component = Qt.createComponent("Info.qml");
                    if (component.status == Component.Ready) {
                        /*
                        * The created object will become a child of the appWindow
                        * item in main.qml.
                        */
                        var object = component.createObject(mainWindow);
                        object.show()
                    } else if (component.status == Component.Error) {
                        // Error Handling
                        console.log("Error loading component:", component.errorString());
                    }
                }
    

    @

    Info.qml:

    @
    Window {
    id: info
    title: qsTr("Info")

        width: 340
        height: 280
        visible: true
    
        Text {
            text: "Hello World!"
            font.pointSize: 24
        }
    

    }
    @

    If I launch the desktop application everything goes well, but if I launch the application in my Android emulator, when I press the menu, I don't see the window.

    It seems it is created because I cannot continue using the application unless I press ESC in the keyboard. I guess that ESC is closing the window.

    Anyway, what is the best way of opening a subwindow using QML?


  • Moderators

    I think Android does not support multi-window applications. However, creating subwindows works fine on Android, when using QtWidgets... so maybe it's a deficiency in the QML port. Try using the newest possible version of Qt, maybe it works there (Qt 5.3.2 snapshot, or 5.4 alpha).



  • So, the Window QML type cannot be used for Android applications?



  • Maybe the port of QML Window to Android is not very well implemented.

    The window is created but not showed. I'm sure the window is running thanks to some logs and because if I touch the screen in the area where the window is supposed to be, the object (i.e. a button) under that area is not receiving the focus or the events.

    So, after this bad experience, I've used a MessageDialog instead of a Window.


  • Moderators

    Good to know, thanks for sharing.



  • Thanks to you, sierdzio.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.