Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Open another QML window

Open another QML window

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.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.
  • A Offline
    A Offline
    AriosJentu
    wrote on last edited by
    #1

    Hi. I'm newbie in development in QT, and I have a question about loading another window when clicking on button in first window. I have two QML files with different styles. I need to open window from second QML when clicking on first.
    I have this:
    My main file calendar.qml:

    import QtQuick 2.2
    import QtQuick.Window 2.10
    ....
    
    Window {
    
        id: root
        visible: true
        ....
        someclasses {
            property variant win;
            MouseArea {
                onClicked: {
                    if (mouse.button === Qt.RightButton) {
                        ....                
                    } else {
                        var component = Qt.createComponent("viewevent.qml");
                        win = component.createObject();
                        //win.show();
                        //win.setEvent(maincalendar.selectedDate, modelData);
                    }
                }
            }
        }
    }
    

    My viewevent.qml file:

    import QtQuick 2.2
    import QtQuick.Window 2.10
    ....
    
    Window {
    
        id: eventWindow
        visible: true
    
        someclasses {
            ....
        }
    
        function setEvent(date, event) {
            ....
        }
    }
    

    So, how can I open window eventWindow from my root, or maybe change view for it, like part of child window in main window. Or maybe any another ideas for creating another 'activity' for application (because it will run on android). Or maybe I need to add in engine this QML, and if it is, how can I do that. And when creating child, how execute it's function (here is setEvent). Thank you.

    DiracsbracketD 1 Reply Last reply
    0
    • A AriosJentu

      Hi. I'm newbie in development in QT, and I have a question about loading another window when clicking on button in first window. I have two QML files with different styles. I need to open window from second QML when clicking on first.
      I have this:
      My main file calendar.qml:

      import QtQuick 2.2
      import QtQuick.Window 2.10
      ....
      
      Window {
      
          id: root
          visible: true
          ....
          someclasses {
              property variant win;
              MouseArea {
                  onClicked: {
                      if (mouse.button === Qt.RightButton) {
                          ....                
                      } else {
                          var component = Qt.createComponent("viewevent.qml");
                          win = component.createObject();
                          //win.show();
                          //win.setEvent(maincalendar.selectedDate, modelData);
                      }
                  }
              }
          }
      }
      

      My viewevent.qml file:

      import QtQuick 2.2
      import QtQuick.Window 2.10
      ....
      
      Window {
      
          id: eventWindow
          visible: true
      
          someclasses {
              ....
          }
      
          function setEvent(date, event) {
              ....
          }
      }
      

      So, how can I open window eventWindow from my root, or maybe change view for it, like part of child window in main window. Or maybe any another ideas for creating another 'activity' for application (because it will run on android). Or maybe I need to add in engine this QML, and if it is, how can I do that. And when creating child, how execute it's function (here is setEvent). Thank you.

      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by Diracsbracket
      #2

      Hi @AriosJentu
      Have a look at https://doc.qt.io/qt-5/qml-qtquick-controls-stackview.html

      A 1 Reply Last reply
      2
      • DiracsbracketD Diracsbracket

        Hi @AriosJentu
        Have a look at https://doc.qt.io/qt-5/qml-qtquick-controls-stackview.html

        A Offline
        A Offline
        AriosJentu
        wrote on last edited by
        #3
        This post is deleted!
        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