Questions tagged [qtreeview]

QTreeView is a class in Qt framework. It provides a default model/view implementation of a tree view.

A QTreeView implements a tree representation of items from a model. This class is used to provide standard hierarchical lists that were previously provided by the QListView class, but using the more flexible approach provided by Qt's model/view architecture.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

823 questions
9
votes
2 answers

QTreeView merge some cells

I have a custom QAbstractItemModel and custom tree view. Is it possible to merge some cells in QTreeView? It shold looks like this: Num | Name | Qty | .... | ----|-----------|-----|------| 1 | Unit one | 5 | .... | 1.1 | Sub unit1 | 3 …
Ivan
  • 490
  • 1
  • 7
  • 23
9
votes
1 answer

Custom text color for certain indexes in QTreeView

I would like to draw texts in one of the columns in a QTreeView widget using a custom color (depending on the data related to each row). I tried to overload the drawRow() protected method and change the style option parameter like this (a…
Vlado Klimovský
  • 531
  • 2
  • 4
  • 12
8
votes
1 answer

QTreeView draw drop indicator

I need to implement rows moving via drag-n-drop in QTreeView and show the drop indicator between rows. I am wondering if there is a way to override indicator drawing, so it is displayed for all levels of hierarchy between rows only (not the…
mentalmushroom
  • 2,261
  • 1
  • 26
  • 34
8
votes
3 answers

QAbstractItemModel data() is NEVER called

I'm attempting to create a QTreeView and use a custom model for it. I have placed qDebug() statements at various places, and I have determined that data() is never being called. How can I fix this problem? The model's code is below #include…
jecjackal
  • 1,407
  • 2
  • 20
  • 35
8
votes
5 answers

QTreeView Horizontal Scrollbar problems

I've a problem with QTreeView horizontal scrollbar, it doesn't appear. I've set horizontal scrollbar policy to ScrollBarAsNeeded, but it doesn't appear if needed. Have tried to connect expanded and collapsed signals to a slot: connect(this,…
Dehumanizer
  • 284
  • 1
  • 3
  • 14
8
votes
2 answers

PyQt: removing QTreeView columns

I am using QTreeView with QFileSystemModel. It displays columns like Size, Type, Modification Date, which I don't need. How can I remove them from the view? I can't find any removeColumn in model or in view.
gruszczy
  • 40,948
  • 31
  • 128
  • 181
8
votes
1 answer

QAbstractItemModel and QTreeView

I need working examples (c++) of show own data model in QtreeView.
Dmitro
  • 1,870
  • 3
  • 16
  • 25
8
votes
1 answer

How to get details about the selected items using QTreeView?

I'm using QTreeView with QDirModel like this: QDirModel * model = new QDirModel; ui->treeView->setModel(model); ui->treeView->setSelectionMode(QTreeView::ExtendedSelection); ui->treeView->setSelectionBehavior(QTreeView::SelectRows); This works…
Keiji
  • 245
  • 1
  • 4
  • 7
8
votes
3 answers

Qt - QTreeView and custom model with checkbox columns

I wanted to have a tree view which shows the item name, the item description, and two related Boolean values in respective columns. I started by modifying the Editable Tree Mode example, so there's a TreeModel that keeps track of a group of…
Ingrid Wu
  • 81
  • 1
  • 1
  • 4
7
votes
3 answers

How to use QSortFilterProxyModel to filter a tree model that only display children nodes with their parents?

I have a working tree model derived from QAbstractItemModel and I wish to filter it using a QSortFilterProxyModel subclass to display only children nodes of certain criteria. For example I have the following tree: A - B -- C1 -- C1 -- C1 --- C2 -…
ksming
  • 1,422
  • 1
  • 16
  • 26
7
votes
1 answer

Single column QTreeview search filter

I have two questions: I was wondering if this is the proper way to do a search/filter on a single column treeview. I feel like a lot of my copying/pasting could contain unnecessary stuff. Is all the code in the subclass of QSortFilterProxyModel and…
JokerMartini
  • 5,674
  • 9
  • 83
  • 193
7
votes
1 answer

Set different images for different checkboxes in a QTreeView

I subclassed a QTreeView and I have two columns where there are checkboxes. I would like to set two different images: one for the first column, and another one for the second column. I know I can change the image in the stylesheet…
IAmInPLS
  • 4,051
  • 4
  • 24
  • 57
7
votes
1 answer

collect all items in QTreeview recursively

How can I collect all Qtreeview items so i can then iterate over them and apply necessary changes like display text updates, or color changes? Is there an easy way to collect all of them using the 'match' method? def get_checked(self): model =…
JokerMartini
  • 5,674
  • 9
  • 83
  • 193
7
votes
5 answers

PyQt: How Can I set row heights of QTreeView

In PyQt, I am looking for a way to set the height of rows in a QTreeView (similarly to QTableView.setRowHeight(row, row_height), but QTreeView does not have this function). QAbstractItemModel is used to set the tree model. I read some suggestions…
Ben
  • 73
  • 1
  • 1
  • 3
7
votes
4 answers

PyQt Tree Widget, adding check boxes for dynamic removal

I am attempting to create a tree widget that will essentially allow the user to view various breakdowns of data and have the option to delete certain items. In order to do this I want to have check boxes associated with each top level item and each…
sudobangbang
  • 1,406
  • 10
  • 32
  • 55
1
2
3
54 55