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
1 answer

Setting QtreeWidget Height

I am new to qt So I don't have much knowledge of sizepolicy and streches of widgets. I have a vertical box layout in which I have first added a Qlabel and then a QTreeWidget and then again a Qlabel. Now the problem is QTreeWidget is taking full…
user3336091
  • 17
  • 1
  • 6
0
votes
1 answer

Char* corrupted when trying to get it / set it

I used to add a feature in my app based on treewidget. When right click on an item, I can create a folder on the FS over USB is used. That mainly say that when selecting an item on the TreeWidget, I get its name and check if it's a folder, if yes, I…
Seb
  • 2,929
  • 4
  • 30
  • 73
0
votes
0 answers

qtreewidgetitem expand action

I have currently design an interface using TreeWidgetItems. I have connected some actions depending on what i want to do. such as below connect(this, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this,…
Seb
  • 2,929
  • 4
  • 30
  • 73
0
votes
2 answers

How to get the new value of a qtreewidgetitem after entering new value

I have created a treewidget and I have added some treewidgetitems which is editable. My goal is now to catch the new value of the item after entering it. Here is the code: QTreeWidgetItem* child = new QTreeWidgetItem(); child->setText(0,…
Seb
  • 2,929
  • 4
  • 30
  • 73
0
votes
1 answer

QTreeWidget Expanding individual Items from memory in C++

I have a Qt QTreeWidget and I am trying to save the state of which header items were expanded so that when I refresh my tree with new information it can re expand the items that were previously expanded. Each time an itemExpanded or itemCollapsed…
silverzx
  • 1,209
  • 4
  • 14
  • 18
0
votes
2 answers

Qt QTreeWidget alternative to IndexFromItem?

I have derived the class QTreeWidget and creating my own QtPropertyTree. In order to populate the tree with widgets (check boxes, buttons, etc) I am using the following code: // in QtPropertyTree.cpp QTreeWidgetItem topItem1 = new…
Cocomico
  • 878
  • 7
  • 18
0
votes
1 answer

How to make QTreeWidget dragging semi-transparent and keep itemWidgets

i have a treeWidget with itemWidget set on columns, but after dragging the widgets are gone, and the dropping indicator is opaque How can i make the widget persist after dropping How to make dropping indicator transparent ? ( i'm on centos 6.5, the…
Shuman
  • 3,914
  • 8
  • 42
  • 65
0
votes
1 answer

Prevent drag outside QTreeWidget

In a QTreeWidget I want to be able to reorder items using InternalMove AND receive drops from another tree in my application. If I set dragDropMode to InternalMove I cannot drop items inside it. However, if I set it to DragDrop it lets the user drag…
0
votes
2 answers

QTreeWidget insertTopLevelItem - index given not accurately displayed in Tree?

I am unable to properly insert a QTreeWidgetItem at a specific index, in this case I am removing all QTreeWidgetItems from the tree, doing a custom sort on their Date Objects and then inserting them back into the QTreeWidget. However, upon…
crackerbunny
  • 139
  • 4
  • 12
0
votes
1 answer

Qt Adjust TreeWidget Row

i have a QTreeWidget with the following structure Row 1 --> QPushButton | |--> Child 1 --> QFrame | |->QVBoxLayout | |->QListView The…
Rui Sebastião
  • 855
  • 1
  • 18
  • 36
0
votes
2 answers

How to make a subchild to a child in QTreeWidget?

I want to make it so that I can expand a third level (subchild) to a child under the top level item (root). All I've been able to do is make multiple children to a single root. this is in my .cpp QStringList string1, string2; …
EricaAKrause
  • 11
  • 1
  • 2
0
votes
1 answer

Context menu only for QTreeWidget children

I would like to show a context Menu in a QTreeWidget only for child items. For the moment, I am getting the index with the following function: def menuItem(self,pos): index = self.ui.tree.indexAt(pos) if not index.isValid(): …
Ucotecnico
  • 3
  • 1
  • 3
0
votes
1 answer

Multiple file insert in QTreewidget using Drag and Drop events

I am working in Qt4.7 on MAC OSx. I want to insert files in QTreewidget using the Drag and Drop events. I want to add multiple files at a time. I am using this: void MainWindow::dragEnterEvent(QDragEnterEvent * e) { …
Ashish
  • 219
  • 2
  • 6
  • 22
0
votes
1 answer

Adding Children in the second column of QTreeWidget using C++

I am making one simple program of in which i have two arrays. I want to insert first array in the first column of the child of treeWidget and second array in the second column of the treeWidget. First array is inserted successfully. Now i want to…
Hamid
  • 137
  • 1
  • 11
0
votes
1 answer

Setting autoscroll in QTreeWidget

I am using QTreeWidget with single column. QTreeWidgetItem has multiple childs in some situations. I am updating dynamically, data in every QTreeWidgetItem. Now when I am adding this data to particular child & I am expanding it. But I am unable to…
userx
  • 806
  • 1
  • 11
  • 23