3

There is a 1 at the top of a QtreeWidget. How do i fix it?

Geore Shg
  • 1,199
  • 3
  • 21
  • 38

3 Answers3

7

The value 1 is the columncount property, that, by default, assumes that value.

Your question was not very clear.

If you want to modify the label, you can use setHeaderLabel/setHeaderLabels functions.

If you want to hide the label, you can use setHeaderHidden function.

Please, before ask, use the Qt documentation.

borges
  • 3,277
  • 3
  • 26
  • 43
  • I came here looking for the same thing this person asking the question was seeking. There is nothing in the QT documentation describing a header - sure there's that function but unless I look through the 30 or so methods, types, and constants in the documentation and examine EVERY one, nobody is going to know what it is - I tried clicking on the 1 and noticed you can't click on it - it doesn't highlight - but that doesn't tell me anything - One would just assume their program isn't working or they don't know properly how to use a QTreeWidget. But this answer helped pointing to a method. – Seth D. Fulmer Mar 22 '20 at 15:24
0

By default qt designer puts 1 there, you need to edit it to suit your need from within qt designer or programatically using the docs.

Andro Selva
  • 51,960
  • 51
  • 189
  • 237
0

This wll change the title of qlistwidget:

self.treeWidget.headerItem().setText(0, QtGui.QApplication.translate("Dialog", "xyz", None, QtGui.QApplication.UnicodeUTF8))

poonam
  • 720
  • 2
  • 17
  • 38