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

How do I know if my Widget is obscured by another application or visible to the user?

Create a new widget, show it, and hide it behind another application. Is there a way to find out if the widget is visible to the user? For example, if you have two applications running and visible to the user (obviously only one of them has focus…
Chenna V
  • 10,185
  • 11
  • 77
  • 104
3
votes
1 answer

How to add a QTableWidget into a QTreeWidget but as a QTreeWidgetItem

I am designing a major interface but had a problem on how to add a QTableWidget into a QTreeWidget but as a QTreeWidgetItem. In order to save everyone's time and provide the best information, below an example that replicate exactly the problem I…
EsoMars
  • 337
  • 3
  • 14
3
votes
1 answer

How do I fully clear a QTreeWidget selection?

I'm trying to make a program that has multiple QTreeWidget's. However, my goal is to ONLY allow for 1 QTreeWidget row to be selected at a time. I've kind of managed to make this happen using the currentItemChanged signal, but it bugs out. To…
Rick
  • 353
  • 1
  • 16
3
votes
1 answer

Qt Drag and drop between QTreeWidget

In my QT application I have two QTreeWidget A and B. I want rewrite drag and drop function for this two behavior: From A to A move items with all childrens. From B to A copy items with all childrens. I have view that in dropEvent function I have…
Catanzaro
  • 1,312
  • 2
  • 13
  • 24
3
votes
2 answers

Removing rows from QTreeWidget (qt programming)

what's the best way to remove a row (QTreeWidgetItem) from a QTreeWidget? The QTreeWidget content has been set by: myQTreeWidget->insertTopLevelItems(0, items); // items = QList then I remove an item from my QList "items" and I…
JuanDeLosMuertos
  • 4,532
  • 15
  • 55
  • 87
3
votes
3 answers

How to iterate subitems of QTreeWidgetItem in Qt

Qt provides QTreeWidgetItemIterator class to iterate through tree view's items. There is even a constructor version which takes the item pointer instead of a view's. Unfortunately, even in this case, the iteration will go down to the very last item.…
def
  • 521
  • 4
  • 16
3
votes
3 answers

QTreeWidget - excluding top level items from sort

I have a 2-level QTreeWidget. The top level only has one column and is just used for grouping the second level, which holds the actual multi-column data. When I sort by clicking on a header (or any other way, really), I only want the second level to…
Natsukane
  • 681
  • 1
  • 8
  • 19
3
votes
0 answers

Extract dictionary from QTreeWidget

I already managed to properly create this treewidget from a dictionary, but now I want to reverse engineer it, and I want to create a dictionary from this qtreewidget. I am quite lost on how to do that, it seems straight forward but I fail. The…
arvidurs
  • 2,853
  • 4
  • 25
  • 36
3
votes
2 answers

QTreeWidget catch item editing finished with no text change

I'm developing a Qt application with QTreeWidget on Qt Designer form. User can press add-new-item button and new item will appear with default name, after that user must enter item's name. So this is my code: void…
serg.v.gusev
  • 501
  • 4
  • 13
3
votes
2 answers

Is it possible to disable the light-blue mouse over highlighting on a QTreeWidgetItem?

I've a QTreeWidget and need to disable the mouse over highlighting on the childItems but not the click selection. The point here is, that I need to set this per Item because some are selectable. I was thinking about the QTreeWidget::itemEntered…
Nitro.de
  • 821
  • 10
  • 27
3
votes
2 answers

How to select an item in QTreeWidget?

I am trying to make a functionality, that will select the last item in the QTreeView, if there are no items selected. I don't know how to select an item within the program. So far I have tried this, but it doesn't work. if (selectedItemList.length()…
Łukasz Przeniosło
  • 2,725
  • 5
  • 38
  • 74
3
votes
0 answers

c++/Qt how to handle clipboard to copy files

c++/Qt how to handle clipboard to copy files Hi, I'm currently developing an app in C++/Qt . I have made some modifications in the Drag and Drop to be able to copy a file from the local machine (Mac OSX) to an Android Device (using the MTP access).…
Seb
  • 2,929
  • 4
  • 30
  • 73
3
votes
1 answer

Signal a QTreeWidgetItem toggled checkbox

How do I check if a checkbox is checked or unchecked? (In QTreeWidget) shows how to get the status of the checkbox on a qtreewidget item. Using that method, with a signal for itemClicked in the Tree, I can query if the selected item is checked or…
user-2147482637
  • 2,115
  • 8
  • 35
  • 56
3
votes
1 answer

QTreeWidget activate item signals

I need to do some actions when item in QTreeWidget activates, but following code doestn't gives me expected result: class MyWidget(QTreeWidget): def __init__(self, parent=None): super(MyWidget, self).__init__(parent) …
serge
  • 405
  • 9
  • 18
3
votes
2 answers

set subchild not to indent in qtreewidget when I expand them

I have a QTreeWidget and I want children of a QTreeWidgetItem not indent when I expand them. I want to set the line only for top items. The first screenshot demonstrates what I would like to have, and the second what I am currently having. Would you…
mari
  • 417
  • 1
  • 6
  • 21