Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved] two forms in one project
Qt 6.11 is out! See what's new in the release blog

[solved] two forms in one project

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • F Offline
      F Offline
      favoritas37
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • F Offline
          F Offline
          favoritas37
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved