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. Assigning index 0 to an item in an SQLite db table field
Forum Update on Monday, May 27th 2025

Assigning index 0 to an item in an SQLite db table field

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 303 Views
  • 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 13 Jul 2019, 20:03 last edited by
    #1

    Hi,
    I have a ComboBox which is populated from an SQLite db. I use the first item in the column as a "placeholder text" so it should stay index 0 to display the right text. The original (unsorted) list looks like this:
    0_1563048001720_2a2d9b5a-1251-4ee7-87c8-1f77aa764816-image.png

    and I want to keep The Friend is a .... text on top.
    After sorting:
    0_1563048073176_d646fa37-4bf5-4ee8-92e1-545028ff977b-image.png

    SO how can I sort everything but also keep The Friend is a .... index on the top?
    Thank you for your help.

    J 1 Reply Last reply 14 Jul 2019, 10:23
    0
    • G gabor53
      13 Jul 2019, 20:03

      Hi,
      I have a ComboBox which is populated from an SQLite db. I use the first item in the column as a "placeholder text" so it should stay index 0 to display the right text. The original (unsorted) list looks like this:
      0_1563048001720_2a2d9b5a-1251-4ee7-87c8-1f77aa764816-image.png

      and I want to keep The Friend is a .... text on top.
      After sorting:
      0_1563048073176_d646fa37-4bf5-4ee8-92e1-545028ff977b-image.png

      SO how can I sort everything but also keep The Friend is a .... index on the top?
      Thank you for your help.

      J Offline
      J Offline
      JonB
      wrote on 14 Jul 2019, 10:23 last edited by JonB
      #2

      @gabor53
      To do your sorting are you interposing a QSortFilterProxyModel as the model between the QComboBox and your QSqlQuery/TableModel for your database?

      And/or/also, how are using "the first item in the column as a "placeholder"? Does it come back as a row from the database, do you insert it somewhere, how/what?

      1 Reply Last reply
      0

      1/2

      13 Jul 2019, 20:03

      • Login

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