Questions tagged [qtreewidget]

QTreeWidget is a class in Qt that provides a tree-like view of data.

This class uses a standard model to hold items, each of them being a QTreeWidgetItem.

Before adding data into the widget, a column count must be specified with setColumnCount() function. The widget can also have a header with a section for each of the columns. It also supports column-based sorting.

A simple example of using this class looks like this:

 //creating a widget
 QTreeWidget *myTreeWidget = new QTreeWidget();
 //adding a column to it
 myTreeWidget->setColumnCount(1);
 //creating a container to temporarily hold the items
 QList<QTreeWidgetItem *> itemList;
 //filling the container with items
 for (int i = 0; i < 10; ++i)
     itemList.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i))));
 //finally, setting the items into the widget.
 myTreeWidget->insertTopLevelItems(0, itemList);

Official documentation can be found here for Qt 4.8 and here for Qt 5.

529 questions
4
votes
0 answers

QTreeWidget border radius toggles visibility during scrolling when set alternating row colors

I am trying to design a QTreeWidget with border-radius. The problem sets in when I assign alternate row colors to it. When I don't, it works fine, and the border-radius around the widget is always visible during scrolling. However, when I scroll…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
4
votes
3 answers

How to insert child into QTreeWidget hierarchy?

Consider I have QTreeWidget with following items hierarchy: top_item |--child Every item has assigned with setItemWidget() widget. I need to insert another child between my first two elements like this : top_item |--another_child …
MaxNes
  • 81
  • 1
  • 1
  • 5
4
votes
2 answers

How do I check if a checkbox is checked or unchecked? (In QTreeWidget)

I have written the code below: from PyQt4 import QtCore, QtGui import sys class window(QtGui.QMainWindow): def __init__(self, parent=None): super(window, self).__init__(parent) self.TreeWidget = QtGui.QTreeWidget() …
Hamzah Akhtar
  • 525
  • 5
  • 13
  • 24
4
votes
2 answers

Expanding width of column in QTreeWidget dynamically

Using PySide, I am developing a small application. In my application, I am using QTreeWidget, to show form like data. This QTreeWidget has single column.My problem is that QTreeWidget not showing horizontal scroll bar when its element expands in…
userx
  • 806
  • 1
  • 11
  • 23
4
votes
1 answer

PySide QTreeWidget clear() causes crash

First of I am new to python and pyside. I have three different QTreeWidgets, representing three different folder structures. When I try to clear them all three in a row the application crashes. widgets = [ self.Delete_treeWidget01,…
Jerakin
  • 455
  • 3
  • 17
4
votes
0 answers

PyQt QTreeWidgetItem argument 1 has unexpected type 'tuple'

Would anyone explain what do I do wrong? I use PyQt4 on Win8. The following is my main code: con = sqlite3.connect('storage.db') with con: cur = con.cursor() cur.execute(script) rows = cur.fetchall() self.treeWidget.clear() for…
Aaron
  • 2,383
  • 3
  • 22
  • 53
4
votes
2 answers

Raise and lower QTreeWidgetItem in a QTreeWidget?

Question says it all how do you raise and lower [change the positions of ] QTreeWidgetItems in a QtreeWidget ,
spearfire
  • 667
  • 1
  • 7
  • 15
4
votes
2 answers

QTreeWidget turn off selection

By default a QTreeWidget manages the selection of rows (when you click a row it highlights it, when you click another row it highlights that and deselects the previous row), I don't want this and cant figure out how to turn it off.
spearfire
  • 667
  • 1
  • 7
  • 15
4
votes
3 answers

Invoking context menu in QTreeWidget

I would like to popup a menu, when user clicks on an object in QTreeWidgetItem. I though about catching signal contextMenuRequested from QWidget and then retrieving index from the view using itemAt. But this doesn't seem very pretty. Is there any…
gruszczy
  • 40,948
  • 31
  • 128
  • 181
4
votes
2 answers

QTreeWidget expand animation on double click

I have created a QTreeWidget and set animation to true (setAnimated(true)). When I'm clicking on a mark (triangle) at the left of item it expands smoothly, but when I'm double clicking on the item it expands too fast (almost like there is no…
yse
  • 41
  • 4
4
votes
1 answer

PyQt4: Display QtSql database in QTreeWidget

How would you display the contents of a QtSql table using a QTreeWidget? There isn't quite enough information around this particular subject...
user1006989
4
votes
1 answer

Multiple Columns in PyQt4 (potentially using QTreeWidget)

I'm trying to get QTreeWidget working exactly similar to this one. In python! I don't care about multiple tabs but about multiple columns. This is what I've got so far. I don't know how to have more than one header though. self.pointListBox =…
Kiarash
  • 7,378
  • 10
  • 44
  • 69
3
votes
2 answers

QTreeView vs setIndexWidget

I am using QStandardItemModel with QStandardItem's. I don't want to write my own model and any delegates. I just want to have tree of checkboxes with QComboBox'es in second column... m_model->setColumnCount(2); for (int i = 0; i < sectionCount;…
k06a
  • 17,755
  • 10
  • 70
  • 110
3
votes
3 answers

Parent-dependent QTreeWidgetItem checkboxes in dynamically generated QTreeWidget

I'm writing an application that has a QTreeWidget that is populated by parsing an XML file containing the tree levels. If I select a top level checkbox, I need all of the sub-level checkboxes to be checked also. I already have the XML parser…
rabidhamper7
  • 161
  • 5
  • 16
3
votes
1 answer

QTreeWidget::currentItem What returns when there is nothing selected?

I am a student programmer using Qt to develop a GUI application. I am using a QTreeWidget to display some properties stored in a vector. In the same window I have the buttons edit, copy, and delete. So far the buttons work to do what they need to;…
Wylie Coyote SG.
  • 1,009
  • 6
  • 22
  • 37