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

QTreewidget only displays first letter of item name

Im learning how to use QTreeWidget and Im stuck adding new items to it. The QTreewidget itself is created with qtdesigner, so my idea was just to add items. eg: tw = self.ui.treeWidget item =…
Hubschr
  • 1,285
  • 6
  • 18
  • 35
0
votes
1 answer

How to read columns in qtreeWidget?

I have two columns in treewidget viz. Files and path. Now I want to dump the items into an xml file. But the issue I'm facing is that I'm unable to extract the items. QDomDocument document; QDomElement root =…
Pride Leo
  • 13
  • 4
0
votes
1 answer

Avoid QTreeWidget scrolling where it wants after selecting item

Inside QTreeWidget implementation, after receiving the signal "item selection changed" and "item selected", it positions the scroll down to put the selected item just in the bottom. It there is no scrollbar, everything goes perfect. Does nothing. I…
Darkgaze
  • 2,280
  • 6
  • 36
  • 59
0
votes
0 answers

QTreewidget scrolling gets slowdown in case of multiple files

I am using QTreewidget in my application. I am filling this QTreewidget on runtime with some files addresses. Now my problem is when there are excess number of files(more than 200) the scrolling gets slow down in the QTreewidget which creates…
Ashish
  • 219
  • 2
  • 6
  • 22
0
votes
1 answer

QTreeWidget drag and drop for reordering selects wrong item

After having followed the recommendations given here : QTreeWidget reordering child items by dragging, the dragged item is not selected. So, quite naturally, I tried to get the dragged item and then call setSelected() on it. The result is that the…
Simon
  • 2,208
  • 4
  • 32
  • 47
0
votes
1 answer

QTreeWidget and QFileSystemModel

Please tell me how to connect to QFileSystemModel QTreeWidget simply function SetModel() not support QFileSystemModel but only QAbstractItemModel, but I need to work with files and for these purposes QAbstractItemModel not fit, I would like to open…
user2759544
  • 181
  • 1
  • 10
0
votes
2 answers

How to build a Qt tree widget step by step, when the user clicks on the branches?

I built a large tree whose branches are loaded from disk, an operation that takes 5 minutes to complete. To speed it up, I want to only load the sub-trees the user selects from the GUI. This is the current code, that loads everything all at…
Pietro
  • 12,086
  • 26
  • 100
  • 193
0
votes
1 answer

Qt QTreeWidget how to get the row a QComboBox is on

I have a QTreeWidget with several QComboBoxes as QTreeWidgetItems. I am trying to find a way to get the current QTreeWidget row of the selected QComboBox. ui->sensorTree is the QTreeWidget. My tree looks something like this: parent0 child0 …
Jared Price
  • 5,217
  • 7
  • 44
  • 74
0
votes
1 answer

Qt get QComboBox->currentText within QTreeWidget

I have a QTreeWidget that contains several QComboBoxes. How can I get the current text of a QComboBox that is in the QTreeWidget? My QTreeWidget looks something like this: ui->sensorTree parent0 child0 QComboBox child1 …
Jared Price
  • 5,217
  • 7
  • 44
  • 74
0
votes
1 answer

Dynamically load/populate data based on scrollbar handle position?

My PyQt application pulls data from third party API calls. The dataset returned usually contains in the neighborhood of hundreds of items. On occasion, the dataset returned contains in the tens of thousands of items. On those occasions, the…
Brian K
  • 545
  • 6
  • 17
0
votes
2 answers

TreeWidget setItemWidget Issue Qt

I am adding a Qwidget(QPushButton) into a QTreeWidget through setItemWidget method, but Button is not appearing as expected. Need some help in this case. Code: import sys from PyQt4 import QtGui, QtCore class Test_Ui(QtGui.QMainWindow): def…
Narayan Singh
  • 1,234
  • 2
  • 13
  • 26
0
votes
1 answer

Retrieve QTreeWidgetItem object at drop event Pyside

I'm writing a program where I need data from the QTreeWidgetItem that has been dropped into another part of my QTreeWidget. The drag and drop is working perfectly, and I am able to get a QEvent.Drop type event in my eventFilter. But I cant get the…
Yvo Götz
  • 15
  • 1
  • 3
0
votes
3 answers

Remove an item of a tree in Qt

I try to remove an item in a QTreeWidget. How can I remove it ? I just want to remove it, not to delete it and I don't find any method.
federem
  • 299
  • 1
  • 6
  • 17
0
votes
2 answers

How to print/export a QTreeWidget content?

Assuming I have a QTreeWidget like that I tried this code to Print/Export this QTreeWidget to a file (The name of this QTreeWidget is trvListVehicle) QPrinter printer(QPrinter::HighResolution); QPainter painter; painter.begin(&printer); double…
Tan Viet
  • 1,983
  • 6
  • 25
  • 36
0
votes
1 answer

Rewrite QTreeWidget >>> QTreeView with checkbox?

I do: class Window(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) self.modelTree = QtGui.QTreeView() self.model = QtGui.QStandardItemModel() self.addItems(self.model, data) …
user7172
  • 874
  • 4
  • 16
  • 31