Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]QModelIndex get data
Forum Update on Monday, May 27th 2025

[Solved]QModelIndex get data

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.5k 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.
  • D Offline
    D Offline
    DarkRoast
    wrote on last edited by
    #1

    Hi all

    I have a QListView with its model set with QSqlQueryModel object.

    The QSqlQueryModel contains a table with two columns (id and name), the QListView is set to show the name

    I have connected the QListView with the signal clicked(), the slot receives a QModelIndex object. How do I get the id from the QSqlQueryModel from the QModelIndex ?

    Thanks
    DarkRoast

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      Just get the sibling on the same row and on the id column. Give a look to QModelIndex methods.

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DarkRoast
        wrote on last edited by
        #3

        Thanks peppe, that did the trick.

        1 Reply Last reply
        0

        • Login

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