Results 1 to 1 of 1

Thread: QT5 (Python) - Get top index parent in a recursive map

  1. #1
    Join Date
    Feb 2021
    Qt products
    Unix/X11 Windows

    Default Re: QT5 (Python) - Get top index parent in a recursive map


    I've with no avail been trying for hours to get the top index parent of a child which has been selected.
    What I'm doing:

    So when you double click ad1-server for example you send the QModel to the function and you can simply do and it returns 'ad1-server'.

    Now ad1-server has variables of its own and when you click on that variable you have to now do QModel.parent().data() to get it to return 'ad1-server' again.

    Now the variables inside of ad1-server also has variables so when you click on that QModel.parent() will now return the previous parent variable instead of ad1-server and I have been trying with different methods to get it to work with no avail.

    How do I get the selected variables Root parent data, for me it is an impossible task at this point.

    I tried this method:

    But this one returns the utter root top item not the root node of the selected item.

    Added after 35 minutes:

    So I solved this by doing it in a while loop:

    root = val.parent()
    while(root.parent().data() != None):
    root = root.parent()
    Last edited by peshmerga; 23rd February 2021 at 21:51.

Similar Threads

  1. Replies: 1
    Last Post: 30th January 2017, 11:42
  2. Replies: 0
    Last Post: 7th January 2017, 00:09
  3. Embedding PyQt4 into an Application running Python via Boost::Python
    By GreyHound in forum Installation and Deployment
    Replies: 1
    Last Post: 6th February 2012, 06:48
  4. Replies: 0
    Last Post: 8th April 2011, 20:10
  5. Obtain index of child's parent
    By webquinty in forum Qt Programming
    Replies: 4
    Last Post: 11th May 2009, 11:57


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.