Results 1 to 3 of 3

Thread: Space in qtreewidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2015
    Posts
    28
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    4

    Default Space in qtreewidget

    I have a QTreeWidget with a few columns in it. All the items in the list appears a bit in from left side, see the attached file. I want them all the way out to the left. This is the code I use for adding items to the list:

    Qt Code:
    1. class PolicyList(QTreeWidget):
    2.  
    3. def addItem(self, ipv4):
    4. self.expandItem(parent)
    5. item = QTreeWidgetItem(self)
    6. item.setText(0, ipv4)
    7. item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsEditable)
    8. item.setIcon(0,self.style().standardIcon(QStyle.SP_FileIcon))
    9. return item
    To copy to clipboard, switch view to plain text mode 

    Screen_Shot_2015_04_19_at_14_16_02.png

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Space in qtreewidget

    Since you set ItemIsUserCheckable, my guess is that empty space is likely where a checkmark will be placed for checked items.

    Cheers,
    _

  3. #3
    Join Date
    Apr 2015
    Posts
    28
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    4

    Default Re: Space in qtreewidget

    No, that's not it. It's not any of the flags, I've tried removing them all.

    How do I know if the item I add is a root item? I get the feeling the space is because of all the items in the list are children to the wrong parents or something.

    EDIT: Got it! QTreeWidget.setRootIsDecorated(False)
    Last edited by ecce; 19th April 2015 at 15:49.

Similar Threads

  1. Replies: 0
    Last Post: 21st October 2013, 10:16
  2. On Press Space Key item in QTreeWidget gets checked.
    By merry in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2012, 10:19
  3. QTableView empty space or too little space.
    By davemar in forum Qt Programming
    Replies: 2
    Last Post: 16th October 2009, 17:00
  4. Replies: 1
    Last Post: 26th July 2009, 16:08
  5. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 9th March 2006, 00:11

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.