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

Qt Ignore Right Click in QItemSelectionModel

Is there anyway to detect which mouse button was clicked from inside a QItemSelectionModel? I want to block a right mouse click from changing the selection. I am using this was a QTreeWidget, so if there is a way to mask the whole thing, that would…
Rafe
  • 1,937
  • 22
  • 31
0
votes
1 answer

Level as list in QtreeWidget

I have vector with 6 numbers, which I want insert to list and add this list to QTreeWidget. First number of list is on "root" level and other numbers are sublevel "root". I don't know how to do it. Image with describe: Code: void modal::zapis()…
avalagne
  • 359
  • 3
  • 7
  • 15
0
votes
1 answer

PyQt QTreeWidget - SIGNAL 'clicked' from header

Is it possible to make the header item of a QTreeWidget clickable ? ( what would be the syntax if it is ? )
Lilley
  • 214
  • 1
  • 5
0
votes
1 answer

pyqt QTreeWidget setColumnWidth not working

So I saw some similar questions posted about this, but maybe I'm just not smart enough to apply it to my situation. In the following example, the only column that seems to be affected by the setColumnWidth is column 0. ''' A custom widget to set up…
user1313404
  • 29
  • 1
  • 4
-1
votes
0 answers

Qt Designer + PyQt5 File Browser dosen't works

I'm trying to make a File Browser with Qt Designer and PyQt5 but it dosen't work well, I think it mitght be the self.ui import sys from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QFileDialog, QTreeWidget, QTreeView,…
-1
votes
1 answer

Why are checkboxes showing through in qt (pyqt) QStyledItemDelegate for TreeWidget

I am trying to build a custom TreeWidget using a QStyledItemDelegate to draw custom checkboxes. Everything is working fine, except when I resize the TreeWidget columns. As you'll see below, when the "Age" column is moved all the way to the left, the…
LozzerJP
  • 856
  • 1
  • 8
  • 23
-1
votes
1 answer

PySide6 QTreeWidget Checkbox SingleSelection

have a PySide6 QTreeWidget with some Elements and Checkboxes, very simple. What i cannot getting to work is how can i make s Single Selection with the Checkboxes? What works is SingleSelection without the Checkboxes, but not when i only use the…
user1701820
  • 31
  • 1
  • 4
-1
votes
1 answer

PySide2 QTreeWidget drag and drop item disappears on Mac, Python2.7

I'm having a problem where a simple QTreeWidget drag and drop of items causes another item to disappear from the tree. This is on Mac Monterey 12.4, using Python 2.7 and PySide2. I swear that it had been previously working on a Windows platform,…
Jesse
  • 143
  • 1
  • 1
  • 10
-1
votes
1 answer

How to open multiple persistent windows in PyQt?

I am trying to display JSON metadata in PyQt6/PySide6 QTreeView. I want to generalize for the case where multiple persistent windows (QtWidgets) pop up if my JSON metadata list has a length greater than 1. for example: def openTreeWidget(app, jmd): …
Ady
  • 9
  • 2
-1
votes
1 answer

Converting a QTreeWidget to a nested dictionary in PyQt

The reason I want to do this is to allow the user to create a file tree using a QTreeWidget, then I want to extract that tree in to a nested dict structure, and save it some how. I've thought about using a txt file and eval aproach to simply load…
-1
votes
1 answer

Creating a Pyqt QtableWidget from a dictionary with list of values, and back to a dictionary

Following on from an earlier question I can now create a Pyqt QTreeWidget from a dictionary, edit the tree and save it to and edited dictionary. However when I comes to dictionary values which contain a list of dictionaries, it compiles the values…
MikG
  • 1,019
  • 1
  • 15
  • 34
-1
votes
1 answer

Creating a tree structure with dict and lists in Python for QTreeView

First of all Im out of practice and Im trying to create a tree structure in Python 3.8 to feed my QTreeView. I read the output of zfs (subprocess.check_output) and split the whole stuff to have a list with pool names: Example list: pools =…
PyCoder
  • 3
  • 2
-1
votes
1 answer

Put item of QTreeWidgetItem into variable

This is the code that i do: `void Tabella::on_pushButton_clicked() { int risultato; risultato = ui->treeWidget->currentItem()->text(2); ui->out_3->setText(QString::number(risultato)); }` Are the any ways to assign the code into…
Shifenis
  • 1,056
  • 11
  • 22
-1
votes
1 answer

PyQt QTreeWidgetItem Individual windows with individual data.

I have a QTreeWidget that contains rows of data for multiple students. When double clicking on a row, a window opens, with a number of drop down menus and text edits that a user can input into. Currently, the user can open the file menu in the top…
DDVlad
  • 7
  • 4
-1
votes
1 answer

which class need to be addressed to support drag'n drop between Qt app and finder

I'm trying to build an app which list the folders and files from an Android device to finder and be able copy from/to PC. I have done the class as below in my Browser.cpp Browser::Browser(USBDevice dev, QWidget *parent) : QTreeWidget(parent) { …
Seb
  • 2,929
  • 4
  • 30
  • 73
1 2 3
35
36