Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Sorting words from SQLite into alphabetical sections
Forum Updated to NodeBB v4.3 + New Features

Sorting words from SQLite into alphabetical sections

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
sqlitelistview
1 Posts 1 Posters 394 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gabor53
    wrote on 18 Aug 2020, 20:26 last edited by
    #1

    Hi,
    I have the following code which is supposed to list the words from an SQLite db into an alphabetized section list (each section corresponds to one letter of the alphabet):

    import Felgo 3.0
    import QtQuick 2.9
    import QtQuick.Controls 2.5
    import QtQuick.Controls.Styles 1.4
    import QtQuick.LocalStorage 2.12
    import "Database.js" as JS
    
    App {
    
        AppListView {
            anchors.fill: parent
    
            // model holds item grouped in sections
            model: ListModel {
                id: listModel
            }
    
            // add sections as regular list items
            delegate: Item {
                width: parent.width
                height: contentCol.height
    
                // each list-entry holds the section header + section items
                Column {
                    id: contentCol
                    width: parent.width
    
                    // header
                    SimpleSection {
                        // manually set otherwise induced section title
                        property string section: model.sectionField
    
                        width: parent.width
                        enabled: true // clickable sections.
    
                        onSelected: {
                            sectionItems.visible = !sectionItems.visible
                        }
                    }
    
                    // items
                    Column {
                        id: sectionItems
                        width: parent.width
    
                        // show all items of section with repeater
                        Repeater {
                            model: listModel
                            delegate: SimpleRow {
                                text: model.wordField
                            }
                        }
                    }
                }
            }
    
            Component.onCompleted: {
                JS.dbGetWordList()
            }
        }
    }
    
    

    Everything works fine except all words appear under each section regardless of their first character:
    Image
    How can I fix this?
    Thank you for your help.

    1 Reply Last reply
    0

    1/1

    18 Aug 2020, 20:26

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved