[solved] two forms in one project



  • Hello,

    I have two main windows for the user to be shown.
    The first should be the initial one which is displayed at the beginning.
    Then there is a button which makes that the other window (form) should be shown instead.

    Therefore I want to make two QML-files and the only thing they have in common is the resolution (the page's width and height).

    How to show the other form (window) = qml file then on the onClick event ???

    Thank you



  • The easiest way would be to create those 2 views, add them in a qml file will you will load and then play with the visibility of the windows.



  • So you mean one qml file and one window is just z ordered over the other one ?



  • The following code does what you want:
    @
    Rectangle{
    id: mainWindow
    anchors.fill:parent

    property bool isWindow1Visible: true;
    
    Rectangle{
        id: window1
        anchors.fill:parent
        visible: isWindow1Visible
    }
    
    Rectangle{
        id: window2
        anchors.fill:parent
        visible: !isWindow1Visible
    }
    
    MouseArea{
        anchors.fill:parent
        onClicked: {
            isWindow1Visible = !isWindow1Visible
        }
    }
    

    }
    @

    No actual z-ordering, simply hide and reveal what you want.

    Also if you are targeting Symbian or Maemo the recommend solution at your problem would be the "Page and PageStack Navigation":http://doc.qt.nokia.com/qt-components-symbian/qt-components-pages-and-navigation-overview.html



  • Yeah, this works.
    Now, I also have an Item which is always visible because it is directly in mainwindow, a sibling of window1 and window2.


Log in to reply
 

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