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
2
votes
2 answers

pyqt linux QListWidget with drag and drop of custom widget disappears

I am trying to implement a custom QListWidget to handle with custom data. I already found out how to display custom widgets in a QListWidget. But when you drag and drop an item, the item disappears. Here is a simple example to show the…
2
votes
1 answer

Can you set the animation speed of a QTreeWidget?

You can set a QTreeWidget to animated with: tree_widget = QtWidgets.QTreeWidget() tree_widget.setAnimated(True) This will make the QTreeWidgetItems animate while they collapse and expand. Is there a way to access and edit the animation speed, and…
Adam Sirrelle
  • 357
  • 8
  • 18
2
votes
1 answer

How to get all items shown in the visible region of a QTreeWidget?

I am making a tree-widget, where I want to get all the items present in the visible region only (not all items present in tree-widget) while scrolling - like below image shown: In the 1st image as you see, I want to get all the items present in the…
Hacker6914
  • 247
  • 1
  • 9
2
votes
1 answer

pyqt5 I want to remove arrow icon in QTreeWidget

Here is my code I Want to remove arrow icon and I want to see only search icon to expand a node. Is there any way to do this? if __name__ == '__main__': # create a empty my_app application my_app = '' # test this my_app to create…
dauren slambekov
  • 378
  • 3
  • 15
2
votes
1 answer

what is the solution of TypeError: QTreeWidget.setModel() is a private method

I am very new to Pyqt5 and am trying to build a GUI. I made a QtreeWidget under Qdockwidget. When I try to set QFileSystemModel with Qtreewidget, python comes up with an error: TypeError: QTreeWidget.setModel() is a private method Below is my .py…
Arif Khan
  • 35
  • 1
  • 5
2
votes
1 answer

Tracking checked items in QTreeWidget when loading in new set of data

I have a QTreeWidget in my gui in which the contents will be cleared whenever it loads in a different set of data and I am trying to tracked what has been checked as User loads in different data set. Initially, I thought of tracking it using…
dissidia
  • 1,531
  • 3
  • 23
  • 53
2
votes
0 answers

Use multiple highlight colors on QTreeWidgetItems in a QTreeWidget

I am trying to create a QTreeWidget that uses a single highlight color for all but the last selection. I am able to change ALL the colors using the setPalette from the QTreeWidget but that only applies to the QTreeWidget and not the…
Nachtwache
  • 103
  • 1
  • 9
2
votes
1 answer

Drag and Drop Data among multiple QTreeWidget

I have a number of QTreeWidget. Here, there are two trees. the left one has "a" , "b". I want to drag this item into the right tree. I have no error but the item become empty. How should I do for dragging the left data to the right tree? and…
Haru
  • 1,884
  • 2
  • 12
  • 30
2
votes
1 answer

How to move items from one QTreeWidget to another QTreeWidget and keep track of information?

I have a GUI where user selects gas components from list and moves it to 'Chosen' and another button takes text from 'Chosen' that has columns: Gas Component, Molecular Weight, Mol%. The first two columns get information from a dictionary that i've…
Drees
  • 688
  • 1
  • 6
  • 21
2
votes
1 answer

how to make a particular column in QTreeWidget integer/Float, such that the user can't enter any alphabets or symbols instead of integers/Floats?

I am making a GUI in PyQt5 which uses QTreeWidget. I want a particular column to be integer only column. The user shouldn't be able to enter any non integer item in it. I saw some methods using QVariant but it doesn't seem to fullfill my…
Star Rider
  • 389
  • 2
  • 15
2
votes
1 answer

Drag items between QTreeWidget and QListWidget in PyQt5?

I have a QListWidget and a QTreeWidget and I want to be able to drag one or multiple list items around within each one as well as between them. I have the internal drag and drop working, but I'm not sure how to drag between them. When I print…
pyjamas
  • 4,608
  • 5
  • 38
  • 70
2
votes
1 answer

How to reach content in QTreeWidget second colum QComboBox?

I have an AppDialog(QtGui.QWidget) containing a QtreeWidget. self.tree = QtGui.QTreeWidget() I populate data from self.sequences to this QtreeWidget with the function seqTree. Datas from self.sequences: {'090': {'090-0010': [ {'code':…
Kevin Lemaire
  • 949
  • 2
  • 12
  • 36
2
votes
1 answer

How I catch Python PyQt5 QTreeWidget pressing enter (return) key?

I am trying to run enterFunc() when pressing enter (return) key. But not working. Here is the code and what is the true code?: class myForm(QMainWindow): ... def keyPressEvent(self,event): if(event.key()==Qt.Key_Enter): …
Aruz
  • 41
  • 7
2
votes
1 answer

How do I get a clicked item in a QTreeWidget?

I have a two-dimensional QTreeWidget, how can I get an Item by clicking on it? I use PyQt5. I have this part of the code, but it gets only the first item of the selected row (or any other by changing the…
Igor Dragushhak
  • 567
  • 1
  • 3
  • 14
2
votes
2 answers

How to set a string property to QTreeWidgetItem?

I have a list of application specific items uniquely identified by an id. Their names are displayed in a QTreeWidget (one item corresponds to a single QTreeWidgetItem). I would like to somehow attach the corresponding ids to these QTreeWidgetItems…
pseudomarvin
  • 1,477
  • 2
  • 17
  • 32