Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Sorting words from SQLite into alphabetical sections

    QML and Qt Quick
    sqlite listview
    1
    1
    201
    Loading More Posts
    • 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
      gabor53 last edited by

      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 Reply Quote 0
      • First post
        Last post