Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QTreeView hideColumn() has no function
Qt 6.11 is out! See what's new in the release blog

QTreeView hideColumn() has no function

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 3 Posters 1.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Frank Winter
    wrote on last edited by
    #1

    Hello, I work on a little pyside2 application with a QTreeView which comes from an ui file.

                self.treeView.setModel(model)
        
                self.treeView.hideColumn(2)
                print(self.treeView.isColumnHidden(1)) # False
                print(self.treeView.isColumnHidden(2)) # True
    

    but column no. 2 is still visible. Are there any requirements for hideColumn() to work properly? Same effect with setColumnHidden(x, True).

    Don't know if it's important: I use a selectionModel and "SingleSelection" mode with "SelectRows" selection behavior. That all works.

    Thanks,
    Frank

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      Hi and welcome to devnet,

      Might be a silly question but how many columns does your model have ?

      Can you provide a minimal example showing that behaviour you have ?

      By the way what bindings are you using ? PySide2 ? PyQt5 ? which version ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Frank Winter
        wrote on last edited by
        #3

        @SGaist thank you very much. The model has 4 columns which are all displayed in the treeview. I will provide an example this evening.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Frank Winter
          wrote on last edited by
          #4

          I've tried it with a simplified version with my Item and ItemModel class (derrived from QAbstractItemModel) and... it works, so I don't post an example here. Have to examine the differences now...

          F 1 Reply Last reply
          0
          • F Frank Winter

            I've tried it with a simplified version with my Item and ItemModel class (derrived from QAbstractItemModel) and... it works, so I don't post an example here. Have to examine the differences now...

            F Offline
            F Offline
            Frank Winter
            wrote on last edited by
            #5

            I've found the solution. After initializing everything I called header().restoreState() to restore column withs and everything, and this resetted my hideColumn settings.

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved