Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jul 2012

    Importance of proper placement of Component.onCompleted in QML

    The following code opens a second page (mainPage) after clicking the OK button of the dialog. The mainPage contains a "Hello" button and clicking it toggles it between "Hello" and "World".

    The code has two lines with "Component.onCompleted". The code, as is, works fine. However, if I uncomment the first "Component.onCompleted" and comment out the second one, the code does not work properly. Clicking the "Hello" button then does nothing. Why is this?

    import QtQuick 1.1
    import com.meego 1.0
    PageStackWindow {
        Page {
            id: mainPage
            Button {
                id: button
                width: parent.width
                text: "Hello"
                onClicked: button.text == "Hello" ? button.text = "World" : button.text = "Hello"
        Page {
            id: firstPage
            Dialog {
                id: myDialog
                buttons: ButtonRow {
                    style: ButtonStyle { }
                    anchors.horizontalCenter: parent.horizontalCenter
                    Button {text: "OK"; onClicked: myDialog.accept()}
                onAccepted: pageStack.replace(mainPage)
    //        Component.onCompleted: myDialog.open();
        initialPage: firstPage
        Component.onCompleted: myDialog.open();

  2. #2
    Regular Contributor
    Join Date
    Mar 2012

    Re: Importance of proper placement of Component.onCompleted in QML

    lemmy guess: cause firstPage is not loaded yet. Page{} loading on demand

Similar Threads

  1. Placement new and instantiated from here..
    By RapchikProgrammer in forum Symbian
    Replies: 4
    Last Post: 2009-02-10, 13:43
  2. UI - Softkeys - Placement
    By nair.shanker in forum Symbian User Interface
    Replies: 1
    Last Post: 2008-10-18, 10:40
  3. Tags: Good Placement?
    By Symbian_Neil in forum Feedback - Nokia Developer Services & Infrastructure
    Replies: 11
    Last Post: 2008-09-27, 14:14
  4. Placement new in Symbian
    By ssn.kishore in forum Symbian
    Replies: 3
    Last Post: 2008-04-16, 15:00
  5. Placement new operator support in V8.0a/v8.1a
    By gaurav17281 in forum Symbian
    Replies: 0
    Last Post: 2006-11-28, 07:35

Posting Permissions

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