×

Discussion Board

Results 1 to 11 of 11

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Apr 2005
    Location
    England
    Posts
    91

    Loader source not being displayed

    I'm trying to use the Loader element to load .qml pages. I've been following the documentation here http://doc.qt.nokia.com/4.7-snapshot/qml-loader.html

    The problem i'm facing, is that when I set loader.source = "Page2.qml", the page isn't shown.
    I have put a console.log on the Page2.qml Component.onCompleted and I can see that log in my Application output, so I know that the Page2.qml is getting loaded, it just isn't displayed.
    Page2.qml displays fine in the qml viewer, so it must be something to do with the way it's loaded.

    Here's the basic code:

    Code:
    Item {
    
        id: homeScreen
        width: 360
        height: 640
    
        Loader {
            id: pageLoader
            anchors.fill: parent
            onLoaded: console.log('loaded')
        }
    
        Button {
            id: button1
            x: 0
            y: 335
            text: "New"
            onClicked: {pageLoader.source = "Page2.qml";  }
        }
    }
    What have I missed?

  2. #2
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Loader source not being displayed

    You cannot see the Page2 element because it's placed under the button.

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    25

    Re: Loader source not being displayed

    Hi hclemson,

    You need to give the height and width of the Loader element "pageLoader", also you have to give x and y position.
    Also you have to set the opacity of the button to 0, and I guess "pageLoader" has its opacity to 1 by default.

    Regards,
    Sauvik Das

  4. #4
    Regular Contributor
    Join Date
    Apr 2005
    Location
    England
    Posts
    91

    Re: Loader source not being displayed

    It was the order of the elements under Item that I had got wrong. Moving the Loader element to the end of the Item solved the problem.

  5. #5
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Loader source not being displayed

    Exactly, that's what I told you!

  6. #6
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,086

    Re: Loader source not being displayed

    Continuing with this thread only , i am having the same issue, here's my page1.qml:

    Code:
    import QtQuick 1.1
    import com.nokia.meego 1.0
    
    Page {
    id:page1
      
        Button{
            id:btn
            anchors {
                horizontalCenter: parent.horizontalCenter
                 topMargin: 10
            }
            text: qsTr("Click to go on page2!")
            //onClicked:pageStack.push(Qt.resolvedUrl("Sample2.qml"));  // this works fine
            onClicked: pageLoader.source = "Sample2.qml"
    
        }
    
        Loader {
            id: pageLoader
            onLoaded: console.log('loaded')
    
        }
    
    }
    I have putted logs inside the Component.OnCompleted() of Sample2.qml , which gets created as well as soon as button is clicked but still the page 1 is in view.

Similar Threads

  1. Replies: 1
    Last Post: 2011-01-30, 15:04
  2. Replies: 3
    Last Post: 2008-07-23, 11:39
  3. Incoming voice calls not being displayed while in J2ME app
    By noreaga in forum Mobile Java General
    Replies: 3
    Last Post: 2006-09-12, 01:42
  4. UI Controls are not being displayed
    By dotcdotc in forum Symbian User Interface
    Replies: 1
    Last Post: 2004-09-27, 05:14

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×