Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Get the database ID of an item

Get the database ID of an item

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 3 Posters 584 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.
  • A Offline
    A Offline
    adrian88888888
    wrote on last edited by
    #1

    alt text

    So far i managed to click an item and it prints his column and row as you can see.

    But since databases uses an ID number:
    -How can i print(or get) the database ID of each item?
    -Or what part of the documentation I should read for that?

    Thanks!

    1 Reply Last reply
    0
    • A adrian88888888

      @SGaist Yes!, i don't use data() because that column maybe will not be visible in the future.

      Sorry for the slow responding:
      alt text

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #4

      @adrian88888888
      If your "database ID of an item" is what you show in your demo column then you must get through data() else there is nowhere else to store it against each line. You may hide that column in your display widget, but you must have it the model, else there will be no way to retrieve it when user clicks.

      A 1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Do you mean the content of the first column ? The one at index 0 ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        A 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Do you mean the content of the first column ? The one at index 0 ?

          A Offline
          A Offline
          adrian88888888
          wrote on last edited by
          #3

          @SGaist Yes!, i don't use data() because that column maybe will not be visible in the future.

          Sorry for the slow responding:
          alt text

          JonBJ 1 Reply Last reply
          0
          • A adrian88888888

            @SGaist Yes!, i don't use data() because that column maybe will not be visible in the future.

            Sorry for the slow responding:
            alt text

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @adrian88888888
            If your "database ID of an item" is what you show in your demo column then you must get through data() else there is nowhere else to store it against each line. You may hide that column in your display widget, but you must have it the model, else there will be no way to retrieve it when user clicks.

            A 1 Reply Last reply
            2
            • JonBJ JonB

              @adrian88888888
              If your "database ID of an item" is what you show in your demo column then you must get through data() else there is nowhere else to store it against each line. You may hide that column in your display widget, but you must have it the model, else there will be no way to retrieve it when user clicks.

              A Offline
              A Offline
              adrian88888888
              wrote on last edited by
              #5

              @JonB thanks for insisting that it was data() the solution, you were right, i didn't know how to correctly use data()

              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