Reply
Thread Tools
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#1
Hi
I'm learning QML.
My code is:
Code:
import QtQuick 1.0
import org.maemo.fremantle 1.0

Column
{
    property color fontcolor: "white"
    Row
    {
        width: parent.width
        CheckBox
        {
            id: tracksrc
            //text: "Select track from library"
            checked: true
            //checkable: true
        }
        Label
        {
            id: tracksrcText
            text: "Select track from library"
            anchors.verticalCenter: tracksrc.verticalCenter
            color: fontcolor
        }
    }

    Label
    {
        id: selecttracklabel
        text: "Selected track"
        color: fontcolor
    }
    Button
    {
        id: selecttrack
        text: "No track selected"
        checkable: false
        width: parent.width
    }

    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 1
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }
    Button
    {
        id: lyricssrcbutton
        text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
        width: parent.width
        onClicked: { lyricssrcdialog.open(); }
    }

    Button
    {
        id: go
        text: "Go!"
        width: parent.width
    }
}
I'm attaching the log.
I want the lyricssrcbutton to display the currently selected option.
Why isn't it working. What's the problem with the loops?
Thanks in advance.
Attached Files
File Type: txt log.txt (6.7 KB, 111 views)
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here

Last edited by marmistrz; 2012-07-13 at 09:04.
 
Posts: 324 | Thanked: 371 times | Joined on Dec 2009 @ Vancouver, BC
#2
The SelectionDialog is in its own Popup window, you can't place it inside a Column/Row, so it's giving you those loop warnings (column and dialog battling out to see who will provide the layout).
 

The Following User Says Thank You to Slocan For This Useful Post:
Posts: 141 | Thanked: 417 times | Joined on Jun 2012 @ Malaysia
#3
@Slocan are right

1 more thing is your SelectionDialog's selectedIndex should be start with 0, not 1
 

The Following User Says Thank You to dicksonleong8 For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#4
I'm still having problems. The index set for 0 solves one the problem of a blank label, but
With this code:
Code:
import QtQuick 1.0
import org.maemo.fremantle 1.0
Rectangle
{
    property color fontcolor: "white"
    Column
    {
        id: c1
        Row
        {
            width: parent.width
            CheckBox
            {
                id: tracksrc
                //text: "Select track from library"
                checked: true
                //checkable: true
            }
            Label
            {
                id: tracksrcText
                text: "Select track from library"
                anchors.verticalCenter: tracksrc.verticalCenter
                color: fontcolor
            }
        }

        Label
        {
            id: selecttracklabel
            text: "Selected track"
            color: fontcolor
        }
        Button
        {
            id: selecttrack
            text: "No track selected"
            checkable: false
            width: parent.width
        }
    }
    Rectangle
    {
        id: r1
        anchors.top: c1.bottom
        SelectionDialog
        {
            id: lyricssrcdialog
            titleText: "Download source"
            selectedIndex: 0
            model: ListModel
            {
                ListElement { name: "AZLyrics" }
            }
        }
        Button
        {
            id: lyricssrcbutton
            text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
            width: parent.width
            onClicked: { lyricssrcdialog.open(); }
        }
    }
    Column
    {
        id: c2
        anchors.top: r1.bottom
        Button
        {
            id: go
            text: "Go!"
            width: parent.width
        }
    }
}
There's only black, blank screen showing up. If only the selectedIndex property is changed:
Code:
import QtQuick 1.0
import org.maemo.fremantle 1.0

Column
{
    property color fontcolor: "white"
    Row
    {
        width: parent.width
        CheckBox
        {
            id: tracksrc
            //text: "Select track from library"
            checked: true
            //checkable: true
        }
        Label
        {
            id: tracksrcText
            text: "Select track from library"
            anchors.verticalCenter: tracksrc.verticalCenter
            color: fontcolor
        }
    }

    Label
    {
        id: selecttracklabel
        text: "Selected track"
        color: fontcolor
    }
    Button
    {
        id: selecttrack
        text: "No track selected"
        checkable: false
        width: parent.width
    }

    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 0
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }
    Button
    {
        id: lyricssrcbutton
        text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
        width: parent.width
        onClicked: { lyricssrcdialog.open(); }
    }

    Button
    {
        id: go
        text: "Go!"
        width: parent.width
    }
}
then it's showing up alright, but throwing that load of loops detected as before. Where should I move the selection dialog?
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here
 
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#5
Originally Posted by marmistrz View Post
then it's showing up alright, but throwing that load of loops detected as before. Where should I move the selection dialog?
Perhaps like this (notice I wrapped Column inside Item):
Code:
Item {

Column
{
    property color fontcolor: "white"
    Row
    {
        width: parent.width
        CheckBox
        {
            id: tracksrc
            //text: "Select track from library"
            checked: true
            //checkable: true
        }
        Label
        {
            id: tracksrcText
            text: "Select track from library"
            anchors.verticalCenter: tracksrc.verticalCenter
            color: fontcolor
        }
    }

    Label
    {
        id: selecttracklabel
        text: "Selected track"
        color: fontcolor
    }
    Button
    {
        id: selecttrack
        text: "No track selected"
        checkable: false
        width: parent.width
    }

    Button
    {
        id: lyricssrcbutton
        text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
        width: parent.width
        onClicked: { lyricssrcdialog.open(); }
    }

    Button
    {
        id: go
        text: "Go!"
        width: parent.width
    }
}


    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 0
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }
}
__________________
My N9/N950 projects:
 

The Following User Says Thank You to ajalkane For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#6
Originally Posted by ajalkane View Post
Perhaps like this (notice I wrapped Column inside Item):
Code:
Item {

Column
{
    property color fontcolor: "white"
    Row
    {
        width: parent.width
        CheckBox
        {
            id: tracksrc
            //text: "Select track from library"
            checked: true
            //checkable: true
        }
        Label
        {
            id: tracksrcText
            text: "Select track from library"
            anchors.verticalCenter: tracksrc.verticalCenter
            color: fontcolor
        }
    }

    Label
    {
        id: selecttracklabel
        text: "Selected track"
        color: fontcolor
    }
    Button
    {
        id: selecttrack
        text: "No track selected"
        checkable: false
        width: parent.width
    }

    Button
    {
        id: lyricssrcbutton
        text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
        width: parent.width
        onClicked: { lyricssrcdialog.open(); }
    }

    Button
    {
        id: go
        text: "Go!"
        width: parent.width
    }
}


    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 0
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }
}
With this code:
Code:
import QtQuick 1.0
import org.maemo.fremantle 1.0
Item
{
    Loader
    {
        id: goloader
        onLoaded: console.log("Go! clicked")
    }
    Loader
    {
        id: selecttrackloader
        onLoaded: console.log("Select track view loaded")
    }

    Column
    {
        property color fontcolor: "white"
        Row
        {
            width: parent.width
            CheckBox
            {
                id: tracksrc
                //text: "Select track from library"
                checked: true
                //checkable: true
            }
            Label
            {
                id: tracksrcText
                text: "Select track from library"
                anchors.verticalCenter: tracksrc.verticalCenter
                color: fontcolor
            }
        }

        Label
        {
            id: selecttracklabel
            text: "Selected track"
            color: fontcolor
        }
        Button
        {
            id: selecttrack
            text: "No track selected"
            checkable: false
            width: parent.width
            onClicked:
            {
            }
        }

        Button
        {
            id: lyricssrcbutton
            text: lyricssrcdialog.model.get(lyricssrcdialog.selectedIndex).name
            width: parent.width
            onClicked: { lyricssrcdialog.open(); }
        }

        Button
        {
            id: go
            text: "Go!"
            width: parent.width
        }
    }


    SelectionDialog
    {
        id: lyricssrcdialog
        titleText: "Download source"
        selectedIndex: 0
        model: ListModel
        {
            ListElement { name: "AZLyrics" }
        }
    }

}
I'm getting
Code:
.../main.qml:53 ReferenceError: Can't find variable fontcolor
.../main.qml:45 ReferenceError: Can't find variable fontcolor
What am I doing wrong?
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here
 
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#7
Originally Posted by marmistrz View Post
With this code:
[CODE]
I'm getting
Code:
.../main.qml:53 ReferenceError: Can't find variable fontcolor
.../main.qml:45 ReferenceError: Can't find variable fontcolor
What am I doing wrong?
I think you can't have property declarations anywhere else than the root item. So try to move 'property color fontcolor: "white"' under Item.
__________________
My N9/N950 projects:
 

The Following User Says Thank You to ajalkane For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#8
Originally Posted by ajalkane View Post
I think you can't have property declarations anywhere else than the root item. So try to move 'property color fontcolor: "white"' under Item.
That way there are no errors, but still somehow only blank screen is painted..
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here
 
Posts: 1,313 | Thanked: 2,977 times | Joined on Jun 2011 @ Finland
#9
Originally Posted by marmistrz View Post
That way there are no errors, but still somehow only blank screen is painted..
That's another problem then. In those kind of situations, I've found it useful to put up a minimal working page (say one component). Then start adding stuff until you've isolated the problem.
__________________
My N9/N950 projects:
 

The Following User Says Thank You to ajalkane For This Useful Post:
Posts: 3,328 | Thanked: 4,476 times | Joined on May 2011 @ Poland
#10
Originally Posted by ajalkane View Post
That's another problem then. In those kind of situations, I've found it useful to put up a minimal working page (say one component). Then start adding stuff until you've isolated the problem.
Wait... Does Item require x,y coordinates? It may be why it's a blank screen. As putting any component in a Rectangle caused not showing up of this component.
__________________
If you want to support my work, you can donate by PayPal or Flattr

Projects no longer actively developed: here
 
Reply


 
Forum Jump


All times are GMT. The time now is 02:49.