Results 1 to 3 of 3

Thread: Is third input to createIndex really a pointer?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2014
    Posts
    98
    Thanks
    43
    Thanked 4 Times in 4 Posts
    Platforms
    Windows

    Default Is third input to createIndex really a pointer?

    I am going through various PySide tutorials, now learning tree views, and trying to understand a couple of things. In the Model class, there is a parent method which (if I am not mistaken) takes in the model, and an index, and returns the index of its parent node. The parent() method calls the built-in method createIndex(), which at the documentation usage is described thusly:

    def createIndex(row, column, ptr): Creates a model index for the given row and column with the internal pointer ptr
    While that is from Qt, the description is the same at PySide documentation site too.

    And in the treemodel tutorial example, within the parent() method, it is used as follows (trimming away some inessential details):
    Qt Code:
    1. def parent(self, childIndex):
    2. childNode = childIndex.internalPointer() #internal pointer returns node corresponding to index
    3. parentNode = childNode.parent() #this instance of parent() is defined in the TreeItem class
    4. return self.createIndex(parentNode.row(), 0, parentNode) #second input is 0 by convention for tree parent
    To copy to clipboard, switch view to plain text mode 
    My question is this: while we indeed use the internal pointer to pull the childNode, this is not the third input to createIndex. Rather, the input to createIndex is simply the parent node which we have pulled from the childNode. So it seems I am not feeding it an internalPointer at all, but simply something I have extracted from the internalPointer.

    Why describe the third parameter as a pointer when it seems to just be an object (i.e., an item/node in your tree)? Given that I am working in Python, which does not use pointers, what is the third input (and for that matter what is an internalPointer anyway, in Python?).

    Note crossposted at SO:
    http://stackoverflow.com/questions/2...-use-a-pointer
    Last edited by neuronet; 15th July 2014 at 17:17.

Similar Threads

  1. Replies: 20
    Last Post: 1st July 2015, 01:19
  2. Replies: 0
    Last Post: 5th December 2013, 06:46
  3. Replies: 0
    Last Post: 28th December 2012, 06:49
  4. Replies: 3
    Last Post: 21st June 2011, 06:25
  5. Replies: 1
    Last Post: 4th December 2010, 17:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.