Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

SimpleSection

A ListView delegate item for displaying sections in a list view. More...

Import Statement: import Felgo 4.0
Since: Felgo 2.6.2
Inherits:

Item

Properties

Signals

Detailed Description

SimpleSection is a simple item intended to be used for the ListView::section.delegate property.

It displays the title of the current section in a row, that uses colors based on the Theme configuration.

When using a ListPage, the ListView::section.delegate property is automatically set to SimpleSection.

Default Usage

The property ListView::section.property may be used to specify the property of the ListView::model data that contains the section. The SimpleSection then automatically displays the content of the section property as the title of the section.

 AppListView {
   model: ListModel {
     ListElement { type: "Fruits"; name: "Banana" }
     ListElement { type: "Fruits"; name: "Apple" }
     ListElement { type: "Vegetables"; name: "Potato" }
   }
   delegate: SimpleRow { text: name }

   section.property: "type"
   section.delegate: SimpleSection { }
 }

Note: For implementing sections with a ListView, only models based on the ListModel type are supported by default. It is possible to use array models with the AppListView::prepareArraySections function.

Advanced Usage

The displayed section title may also be set manually. Within the section delegate, three attached properties are available per default:

  • section - Holds the value of the current section.
  • nextSection - Returns the title of the next section.
  • previousSection - The previous section.

In addition, it is possible to fully customize the internal Text item with the textItem property. Another feature is to allow click events on sections. The next example creates clickable sections with a custom title.

 AppListView {
   model: ListModel {
     ListElement { type: "Fruits"; name: "Banana" }
     ListElement { type: "Fruits"; name: "Apple" }
     ListElement { type: "Vegetables"; name: "Potato" }
   }
   delegate: SimpleRow { text: name }

   section.property: "type"
   section.delegate: SimpleSection {
     title: "Category: "+section // E.g. "Category: Fruits"
     textItem.horizontalAlignment: Text.AlignHCenter // center text horizontally
     enabled: true // make section clickable
     onSelected: {
       console.log("Section Selected: "+section)
       }
   }
 }

Section Styles

The SimpleSection::style property allows to either change certain styling properties or even set a completely individual style based on the StyleSimpleSection type. By default, there are already two different styles available that are based on the Theme::listSection and Theme::listSectionCompact configuration. Use the property SimpleSection::style.compactStyle to switch between these two default styles. Initially it is set to false.

Property Documentation

The StyleSimpleSection configuration sets the colors and sizes to be used for the SimpleSection. The default style uses the standard configuration of the Theme::listSection configuration. Set style.compactStyle to true in order to switch to the Theme::listSectionCompact default configuration.


textItem : alias

Allows accessing the Text item within the SimpleSection. May be used to change the font or other Text properties.


title : string

The section title to display.


Signal Documentation

selected(string section)

Emitted when this row has been clicked. The section parameter contains the section title.

Note: The corresponding handler is onSelected.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded