Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How do I remove header labels from my tree view?
Qt 6.12 LTS is out! See what's new in the release blog

How do I remove header labels from my tree view?

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 1.0k Views 1 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.
  • I Offline
    I Offline
    IDontKnowHowToCode
    wrote on last edited by
    #1

    If you just set the header labels with "model.setHorizontalHeaderLabels", it will still keep the old labels if the list of new labels is shorter than the previous labels. For example:

            self.setHorizontalHeaderLabels(["test", "test2"])
            self.setHorizontalHeaderLabels(["test3"])
    

    After running this code in my item model, the header looks like this:
    cd71cad2-1eeb-4b06-b2f3-5185f8ac10d6-image.png

    Clearly "test" was overwritten, but test2 stays. How can I remove test2? There are no items that go in its column.

    SGaistS 1 Reply Last reply
    0
    • I IDontKnowHowToCode

      If you just set the header labels with "model.setHorizontalHeaderLabels", it will still keep the old labels if the list of new labels is shorter than the previous labels. For example:

              self.setHorizontalHeaderLabels(["test", "test2"])
              self.setHorizontalHeaderLabels(["test3"])
      

      After running this code in my item model, the header looks like this:
      cd71cad2-1eeb-4b06-b2f3-5185f8ac10d6-image.png

      Clearly "test" was overwritten, but test2 stays. How can I remove test2? There are no items that go in its column.

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Use an empty string for that column.

      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

      • Login

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