Results 1 to 4 of 4

Thread: [pyqt]Overriding operator< in QTreeWidgetItem

  1. #1
    Join Date
    Apr 2011
    Posts
    3
    Thanks
    1
    Qt products
    Platforms
    Unix/X11 Windows

    Default [pyqt]Overriding operator< in QTreeWidgetItem

    Hello!

    Could you tell me how should I implement the override of operator< in QTreeWidgetItem?
    I am asking because I can't find source code of original QTreeWidgetItem implementation in Python and I just don't know how it looks like.

  2. #2
    Join Date
    May 2011
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [pyqt]Overriding operator< in QTreeWidgetItem

    hi,
    i have the same question. did you solve it ?

  3. #3
    Join Date
    Apr 2011
    Posts
    3
    Thanks
    1
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: [pyqt]Overriding operator< in QTreeWidgetItem

    I receive private messages with question whether I found the answer to my question. Unfortunately, I still don't know how to override operator. I even posted exactly the same question on PyQT mailling list: http://article.gmane.org/gmane.comp....iding+operator

    Again, no response I got...

    I promise to post solution as soon as I find the answer .

    Please don't hesitate to post your own solution in this thread if you have it ...

  4. #4
    Join Date
    May 2011
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [pyqt]Overriding operator< in QTreeWidgetItem

    hi, I'm sorry that I forgot to post solution i have found some time later:

    Qt Code:
    1. class myTreeWidgetItem( QTreeWidgetItem ):
    2. def __init__(self, parent=None):
    3. QTreeWidgetItem.__init__(self, parent)
    4.  
    5. def __lt__(self, otherItem):
    6. column = self.treeWidget().sortColumn()
    7.  
    8. if column == 0 or column == 6 or column == 7 or column == 8:
    9. return float( self.text(column) ) < float( otherItem.text(column) )
    10. else:
    11. return self.text(column) < otherItem.text(column)
    To copy to clipboard, switch view to plain text mode 


    or http://stackoverflow.com/questions/3...ewidget-column
    Last edited by univerz; 19th September 2011 at 20:30.

  5. The following user says thank you to univerz for this useful post:

    kosset (19th September 2011)

Similar Threads

  1. Overriding global new
    By branko in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2010, 17:10
  2. Replies: 5
    Last Post: 23rd September 2010, 14:58
  3. Overriding drawRubberBand()
    By andrew.nguyen in forum Qwt
    Replies: 3
    Last Post: 21st April 2010, 07:58
  4. PyQt remove the current QTreeWidgetItem
    By koenux in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2009, 00:08
  5. Overriding QListView painting
    By efegea in forum Qt Programming
    Replies: 2
    Last Post: 29th November 2008, 18:16

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.