Forums

OverviewFelgo 2 Support (Qt 5) › Loader can't load leveled qml file

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18671

    Niyazi

    Hi,

    Here is my basic project settings layout

    • Main.qml
    • mainui FOLDER
      • Header.qml
      • branch.qml

    I can load Header.qml into (top of) Main.qml. In my header there is a text as “Branch”. When user clicks the Branch text the mousearea onclicked supposed to load

    branch.qml in to main.qml. In my main.qml I define the loader as shown below.:

     

    In Header.qml Text {} mouseArea

    
                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            pageLoader.source = "branch.qml"
                            console.debug("onClicked Loader Fired")
    
                        }
                    }

     

    in Main.qml

          Loader {
            id: pageLoader
            anchors.fill: parent
        }

     

     

     

    #18677

    Niyazi

    I couldn’t delete my first questions. I am trying to be more clear so, I can get help.

    My question is in map.qml MouseArea section. Any help please?

     

    QML FOLDER
    	MainApp.qml
    	MainAppPage.qml
    	mainui FOLDER
    		header.qml
    		map.qml
    		
    
    MainApp.qml
    --------------------
    import Felgo 3.0
    import QtQuick 2.10
    import QtQuick.Controls 2.2
    
    import "singletons"
    import "components"
    import "mainui"
    import "."
    
    App {
        //licenseKey: "<generate one from https://felgo.com/licenseKey>"
        id: rootApp
    
        FontLoader {
            id: normalFont
            source: "../assets/fonts/Lato-Light.ttf"
        }
    
        onInitTheme: {
            Theme.platform = "ios"
            settings.language = "tr_TR"
            uiScale: 1  // (1) for Mobiles and (2) for Desktops
            Theme.colors.statusBarStyle = Theme.colors.statusBarStyleHidden
            //Theme.normalFont = normalFont
        }
    
        Loader {
            id: loaderPage
            anchors.fill: parent
    
          }
    
        CapitalMainPage {
    
        }
    }
    
    
    MainAppPage.qml
    -------------------
    import Felgo 3.0
    import QtQuick 2.10
    import QtQuick.Controls 2.2
    
    import "singletons"
    import "components"
    import "mainui"
    import "."
    
    
    Page {
        id: mainPage
        anchors.fill: parent
    
        // Background Image
        Image{
            anchors.fill: parent
            source: "../assets/BgTemplate/1.jpg"
        }
    
        // Top Contenet
        header {
            anchors.top: parent.top
            z: 1
        }
    
    }
    
    
    
    header.qml
    --------------------
    import Felgo 3.0
    import QtQuick 2.10
    import QtQuick.Layouts 1.3
    import QtQuick.Controls 2.2
    
    import "../singletons"
    import "../../qml"
    import "."
    
    
    Rectangle {
        id: topContentRect
        width: parent.width
        height: dp(30)
        color: "#00000000"
    
    
        RowLayout {
            id: topLayout
            anchors.fill: parent
    
            Text {
                id: atmLabel
                anchors.left: parent.left
                anchors.leftMargin: dp(5)
                font.family: normalFont.name
                font.pixelSize: sp(CbStyle.headerFontSize)
                font.bold: CbStyle.headerFontBold
                color: "#ffffff"
                text: qsTr("Map")
    
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        mainPage.visible = false
                        loaderPage.source = "map.qml"
                        loaderPage.Top
                        console.debug("onClicked Loader Fired")
                    }
                }
            }
    	}
    }
    
    
    
    map.qml
    --------------------
    import Felgo 3.0
    import QtQuick 2.10
    import QtQuick.Layouts 1.3
    import QtQuick.Controls 2.2
    
    import "../singletons"
    import "../../qml"
    import "."
    
    
    Rectangle {
        id: atmMap
        anchors.fill: parent
    
        Text {
            id: atmLabelExit
            anchors.left: parent.left
            anchors.leftMargin: dp(20)
            anchors.top: parent.top
            anchors.topMargin: dp(20)
            font.family: normalFont.name
            font.pixelSize: sp(CbStyle.headerFontSize)
            font.bold: CbStyle.headerFontBold
            color: "#000000"
            text: qsTr("Exit")
    
    
            MouseArea {
                anchors.fill: parent
                onClicked: {             
                    atmMap.visible = false
                    
    				// IN HERE I NEED TO CLOSE MAP.QML and ACTIVATE MAIN-APP-PAGE AGAIN.
    				// HOW DO I DO THAT?
                    
                }
            }
        }
    
    
        Rectangle {
            anchors.fill: parent
            color: "red"
            opacity: 0.25
        }
    
    }
    
    
    
    

     

    #18684

    Günther
    Felgo Team

    Do you use the app Navigation system with Navigation / NavigationStack to show your pages?

    In this case, you can create an alias property to these items, which control the shown pages.

    For example:

    MyNavigationQmlFile:

    import Felgo 3.0
    
    App {
      anchors.fill: parent
    
      property alias appNavigation: appNav
      Navigation {
          id: appNav
          // ...
       }
    }

    You can then e.g. use

    appNavigation.currentNavigationItem.navigationStack.popAllExceptFirst()

    anywhere in your code.

     

    Best,
    Günter

    asdf

    #18689

    Niyazi
Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support