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. Is there a simpler way to extract the data from a Qmodel index without referencing the standard_model instantiation
Forum Updated to NodeBB v4.3 + New Features

Is there a simpler way to extract the data from a Qmodel index without referencing the standard_model instantiation

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 333 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.
  • H Offline
    H Offline
    hwstar
    wrote on last edited by
    #1

    I have this code which works but seems clunky:

           model_index_of_pn = self._standard_model.index(pn_node.row(), 0)
                pn = model_index_of_pn.data()
                model_index_of_desc = self._standard_model.index(pn_node.row(), 1)
                desc = model_index_of_desc.data()
    
    

    I'm extracting the data for two columns on the selected row.

    I think the data I need can be referenced by just using pn_node QModelIndex instantiation, but I can't seem to make it work after looking at the docs for QModelIndex

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

      Hi,

      Aren't you looking for QModelIndex::sibling ?
      Don't forget to check for the validity of the index returned.

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

      1 Reply Last reply
      1
      • H Offline
        H Offline
        hwstar
        wrote on last edited by
        #3

        Thank you.
        I overlooked this in the docs because I thought it would give me a child node which is not what I want.

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

          You're welcome !

          Since this is what you wanted, please mark the thread as solved using the "Topic Tool" button or the three dotted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)

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

          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