• May 19, 2024, 10:09:04 pm

Author Topic: Flickable List with List Heading QML  (Read 1304 times)

0 Members and 1 Guest are viewing this topic.

Offline Allstar12345

  • Allstar Software Founder
  • Administrator
  • Forum Genius
  • ******
  • Posts: 5,235
  • Reputation: 812
    • Allstar Software
  • Current Phone: : OnePlus 8 Pro, Xperia 10, Nexus 6p, Jolla Phone, Nokia N8, Nokia 808 PureView, BlackBerry Z30
Flickable List with List Heading QML
« on: June 01, 2013, 03:49:52 am »
Using a List on QML is a neat way to organize options, information ect.

First we start with the Flickable (It doesn't really need one but it let's you scroll when you run our of space):

This includes a Column to keep it in shape, this one is simple anchors to fill the parent component.

Code: [Select]
Flickable {
        id: flickable1
        anchors.fill: parent
        contentHeight: list.height
        contentWidth: list.width
       
        Column {
            id: list
}
}


Now after that you can make a ListHeading as so, this one has the text anchored to the center of the ListHeading:

Code: [Select]
ListHeading {
        id: head
        ListItemText {
        id: headingText
            anchors.centerIn: parent
        role: "Heading"
        text: "TEXT GOES HERE"
        }
        }


Now you can add a ListItem with Text, again this one is anchored to center into the Item (Looks better in my opinion)

Code: [Select]
ListItem {
        id: list1
        enabled: true
        onClicked:{ Console.log("List clicked)
        }
        ListItemText {
        role: "Title"
        text: "Click Me"
        anchors.centerIn: parent
        }
        }

You need to place the ListItem's between the Column like so:

Code: [Select]
Flickable {
        id: flickable1
        anchors.fill: parent
        contentHeight: list.height
        contentWidth: list.width
       
        Column {
            id: list
ListHeading {
        id: head
        ListItemText {
        id: headingText
            anchors.centerIn: parent
        role: "Heading"
        text: "TEXT GOES HERE"
        }
        }
ListItem {
        id: list1
        enabled: true
        onClicked:{ Console.log("List clicked)
        }
        ListItemText {
        role: "Title"
        text: "Click Me"
        anchors.centerIn: parent
        }
        }

}
}


Offline Allstar12345

  • Allstar Software Founder
  • Administrator
  • Forum Genius
  • ******
  • Posts: 5,235
  • Reputation: 812
    • Allstar Software
  • Current Phone: : OnePlus 8 Pro, Xperia 10, Nexus 6p, Jolla Phone, Nokia N8, Nokia 808 PureView, BlackBerry Z30
Re: Flickable List with List Heading QML
« Reply #1 on: June 01, 2013, 03:55:20 am »
You can also add a Scroll Decorator so you know how far down the list you are:

Code: [Select]

        ScrollDecorator {
             id: scrolldecorator
             flickableItem: flickable1
         }

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
Re: Flickable List with List Heading QML
« Reply #2 on: June 01, 2013, 04:03:19 am »
this looks soooo cute, like MeeGo :)

without you I never would know about QML and use Buttons with fixed positions :P

Offline Allstar12345

  • Allstar Software Founder
  • Administrator
  • Forum Genius
  • ******
  • Posts: 5,235
  • Reputation: 812
    • Allstar Software
  • Current Phone: : OnePlus 8 Pro, Xperia 10, Nexus 6p, Jolla Phone, Nokia N8, Nokia 808 PureView, BlackBerry Z30
Re: Flickable List with List Heading QML
« Reply #3 on: June 01, 2013, 04:15:48 am »
this looks soooo cute, like MeeGo :)

without you I never would know about QML and use Buttons with fixed positions :P

We are all taught me someone ;) , Mangolazi and Anand taught me the very basics..