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
4 answers

How can i hide the border for qtreeview?

I want to hide the border of the QTreeWidget i´m customizing. I want it to be the same when i select an item inside. But this special outline doesn´t work at all. I want it to be the same as the first image. I use this piece of css code:…
Darkgaze
  • 2,280
  • 6
  • 36
  • 59
0
votes
1 answer

how to delete checked items from QTreeWidget?

I have list of QTreeWidget items with check boxes, which are child items with few top level items. I want to delete the items which are in checked state, how can I iterate the qtreewidget and delete those items ?
Prady
  • 663
  • 3
  • 11
  • 28
0
votes
0 answers

Why there is no find item to get a unique item in QTreeWidget?

I have unique QTreeWidgetItems in QTreeWidget, I am using findItems() to find a specific item, it returns list of items. From this list taking the first item and storing in QTreeWidgetItem. but i wonder is there any method to find an item which…
Prady
  • 663
  • 3
  • 11
  • 28
0
votes
1 answer

Memory leak when inserting elements in a QTreeWidget?

When I insert elements into a QTreeWidget, I allocate memory for both QStringList and QTreeWidgetItem QStringList *temp; while(other_elements) { temp = new QStringList(); temp->push_back("first_field"); temp->push_back("second_field"); …
Johnny Pauling
  • 12,701
  • 18
  • 65
  • 108
0
votes
1 answer

Single QTreeWidgetItem instance on multiple QTreeWidget?

I'm trying to show a single QTreeWidgetItem instance on 2 QTreeWidgets, which ends up the item shown only on the 1st tree without being notified. I haven't seen its API doc talks about a limitation if any. Is there a way to…
IsaacS
  • 3,551
  • 6
  • 39
  • 61
0
votes
1 answer

Using QFileSystemModel along QTreeView and QTreeWidgetItem

I have a "project structure", which is something like this. -Project Main File --Project Subfile 1 --Project Subfile 2 --Project Subfolder 1 ---Project Subfolder 2 ----Project Subfile 3 I'm using a QFileSystemModel to get the files on the specified…
0
votes
2 answers

QTreeWidget (Applying Styles for items)

I have a tree widget and there are three levels in the tree as follows Example Tree ============================ LEVEL1 LEVEL2 LEVEL2 LEVEL3 LEVEL3 LEVEL2 LEVEL2 LEVEL1 I want to apply different styles for items,…
warunanc
  • 2,221
  • 1
  • 23
  • 40
0
votes
1 answer

How to pop menu at QTreeWidgetItem‘s coordinates?

In QT:I craete a QMenu: QMenu* popMenu = new QMenu(ui->treeWidget); and I want to pop it above the current treewidgetitem, but what I only know is: popMenu->exec(QCursor::pos()); So if I use: ui->treeWidget->setCurrentItem(treeWidgetItem);//this…
Al2O3
  • 3,103
  • 4
  • 26
  • 52
0
votes
1 answer

PyQt4: setVerticalHeaderLabels to checkbox

How can you setVerticalHeaderLabels of a QTableWidget to a checkbox if possible using python? This would be the relevant part of the code... #!/usr/bin/env python #-*- coding:utf-8 -*- import sys from PyQt4.QtCore import * from PyQt4.QtGui import…
user1006989
0
votes
2 answers

vertical header labels in QTreeWidget

I have a QTreeWidget with horizontal header labels at the moment and my intention is to draw only the headerLabels vertically and the rest horizontally. I don't want to reimplement everything in QTreeWidgets's paintEvent method, so I am thinking…
Arnab Datta
  • 5,356
  • 10
  • 41
  • 67
0
votes
1 answer

Focusing on last data entry on Qtreewidget

I am trying to use Qtreewidget as listview (like in C#) to display some data. As seen on the image below, while new datas displayed during the runtime, the widget doesn't focus on the last entry.That is what I want but couldn't find a method to make…
Horizon1710
  • 792
  • 10
  • 28
0
votes
2 answers

Python parent in QTreeWidget

I am working on python plugins.I used QTreeWidget to list items. [listing in qtreewidget][1] this link helped me a lot. My code is: valestimate=QTreeWidgetItem(str(parent_name)) for row in c.fetchall(): …
poonam
  • 748
  • 4
  • 19
  • 40
0
votes
2 answers

Python Query Result in QTreeWidget

I am working on python plugins.I used PyQt4 Designer. I want to list query result into QTreeWidget. My code is as follows: c = self.db.con.cursor() self.db._exec_sql(c, "select est from bio") for row in c.fetchall(): item_value=unicode(row[0]) …
poonam
  • 748
  • 4
  • 19
  • 40
0
votes
1 answer

Sort a QTreeWidgetItem by a data value?

Is it possible to sort a PyQt QTreeWidget by a QTreeWidgetItem's data column? For example, I've got a list of directories I want to sort by size on disk displaying in the QTreeWidget, but instead of displaying the results (in bytes) I use a method…
mfessenden
  • 598
  • 4
  • 12
0
votes
2 answers

how to call myslot using item click signal in QTreeWidget

Want to trigger "itemClicked" event for a QTreeWidget Item using the following code. connect(aTreeWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(CallM(QTreeWidgetItem* item, int))); but the CallM slot is not called,don't no what is the…
Prady
  • 663
  • 3
  • 11
  • 28