Results 1 to 3 of 3

Thread: PyQt Vertical Header Icons?

  1. #1
    Join Date
    Dec 2014
    Posts
    48
    Thanks
    23
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    Windows

    Default PyQt Vertical Header Icons?

    Hoping to emplace an (repetitive) icon for each vertical header (row).
    Currently the header 'box' is empty; without any text - yet efforts to set via headerData() function in AbstractTableModel do not seem to work.

    Below is the current non-functioning script(s):
    Qt Code:
    1. def headerData(self,section,orientation,role):
    2. if role != Qt.DisplayRole:
    3. return
    4. if orientation == Qt.Vertical and role == Qt.DecorationRole:
    5. return QtGui.QIcon(r'C:\Program Files\QGIS Brighton\apps\qgis\python\plugins\GraphicGroundwater\buttons\zoomAndDrag.png')
    6.  
    7. if orientation == Qt.Horizontal:
    8. return self.header[section]
    To copy to clipboard, switch view to plain text mode 

    Thousand thanks for any clues.

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: PyQt Vertical Header Icons?

    You are returning if the role is not Qt.DisplayRole, which means your next if statement can never be true.

  3. The following user says thank you to jefftee for this useful post:

    jkrienert (20th January 2015)

  4. #3
    Join Date
    Dec 2014
    Posts
    48
    Thanks
    23
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    Windows

    Default [SOLVED] PyQt Vertical Header Icons?

    jthomps,
    Ridiculous I didn't realize that. Thank you.
    The following got things working (although I suppose the first if-pass statement isn't all together necessary):
    Qt Code:
    1. def headerData(self,section,orientation,role):
    2. if role != Qt.DisplayRole:
    3. pass
    4. if orientation == Qt.Vertical and role == Qt.DecorationRole:
    5. return QtGui.QIcon(r'...\buttons\zoomAndDrag.png')
    6. if orientation == Qt.Horizontal and role == Qt.DisplayRole:
    7. return self.header[section]
    To copy to clipboard, switch view to plain text mode 

    Again, a thousand thanks jthomps.
    Last edited by jkrienert; 20th January 2015 at 00:43. Reason: updated contents

Similar Threads

  1. Replies: 2
    Last Post: 26th November 2013, 16:58
  2. [PyQt] QTableView not showing vertical scroll bar
    By Gad82 in forum Qt Programming
    Replies: 3
    Last Post: 23rd November 2012, 15:55
  3. Vertical Header For QTreeView
    By wirasto in forum Qt-based Software
    Replies: 1
    Last Post: 12th October 2010, 06:53
  4. Qtableview Vertical header order
    By Darthspawn in forum Qt Programming
    Replies: 4
    Last Post: 26th March 2010, 16:10
  5. No Sort Vertical Header
    By wirasto in forum Qt Programming
    Replies: 4
    Last Post: 1st July 2009, 11:54

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.