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
5
votes
2 answers

Assigning Icons to items in QTreeView

I have a class inheriting from QTreeView. I need to assign icons to different types of files and directories. There is this solution given from this question: QVariant MyQFileSystemModel::data( const QModelIndex& index, int role ) const { if(…
Amani
  • 16,245
  • 29
  • 103
  • 153
5
votes
4 answers

Qt: View not updating after QAbstractItemModel::beginInsertRows/endInsertRows

I have a QAbstractItemModel derived model attached to a QTreeView I want to programatically append a single row to a node somewhere in my tree hierarchy. I have a slot which is connected to a signal from my view. The signal sends the QModelIndex of…
Steve Lorimer
  • 27,059
  • 17
  • 118
  • 213
5
votes
1 answer

PySide: Instant tooltips (no delay before showing the tooltip)

The tool I'm building uses tooltips to display extra info about a file before you click on it. It would be great if someone could lend some insight into how to accomplish this. I'm about a month into PySide so I'm having trouble deciphering these…
Mike Bourbeau
  • 481
  • 11
  • 29
5
votes
1 answer

PyQt: change the alignment of checkboxes in a QTableView

I have a QTableView with checkbox, but the checkbox is aligned left, and I need to align it center. I tried this, but I have a problem with the "check" function: def drawCheck(self, painter, option, rect, state): textMargin =…
ekapek
  • 193
  • 2
  • 8
5
votes
2 answers

Recursively expand all child items of item in QTreeView

I have a QTreeView and I want to expand all child items of a recently expanded item. I tried using .expandAll(), but it expand all others items also. I'm having a hard time to get the ModelIndex of the item that was lastly expanded, If i do have it…
f.rodrigues
  • 3,499
  • 6
  • 26
  • 62
5
votes
1 answer

Multi-level QTreeView

I'm having a hard time understanding how to set a multilevel QTree using the QTreeView and QStandardItemModel. Here's what I have: from PySide.QtGui import * import sys class MainFrame(QWidget): def __init__(self): …
f.rodrigues
  • 3,499
  • 6
  • 26
  • 62
5
votes
2 answers

Qt: set columns in treeView

How can I implement this code I have for a qTreeWidget for a qTreeView? for (const auto & i : names) { QTreeWidgetItem * item = new QTreeWidgetItem(ui->treeWidget); item->setText(0, QString::fromStdString(i)); …
gartenriese
  • 4,131
  • 6
  • 36
  • 60
5
votes
1 answer

Adding Vertical headers to a QTreeView

I have a QTreeView subclass (and QAbstractItemModel subclass) which has a nice horizontal header. I would like to add vertical headers (going down the left side) to match. But unlike QTableView which has separate vertical (setVerticalHeader()) and…
Adam Batkin
  • 51,711
  • 9
  • 123
  • 115
5
votes
1 answer

How can I get the size/depth/branches of a QTreeView?

I cannot find any method to get the size, depth, and number of branches of a QTreeView. I do not mean the size of its graphical representation, but the size of the data stored in the tree.
Pietro
  • 12,086
  • 26
  • 100
  • 193
5
votes
2 answers

Wrong text alignment in row using QTreeView

I have a QTreeView (with PyQt4) with custom and resized icons using the code below, but the Size column is displaying a wrong alignment/position, like so: self.ui.treeView.setIconSize(QtCore.QSize(30,30)) fileSystemModel =…
neowinston
  • 7,584
  • 10
  • 52
  • 83
5
votes
4 answers

how set QCheckBox in QAbstractItemModel?

I have a model class TreeModel : public QAbstractItemModel which I populate with instances of my TreeItem excluding column==1. In column 1 I've created CheckBoxes: QVariant TreeModel::data(const QModelIndex &index, int role) const { if…
4pie0
  • 29,204
  • 9
  • 82
  • 118
5
votes
1 answer

When to emit dataChanged from a QAbstractItemModel

In Qt, I have a model subclassing QAbstractItemModel - it's a tree displayed in a QTreeView. The model supports various forms of change which all work OK. The two of relevance are: 1) Some data in a small number of related rows changes 2) A…
strubbly
  • 3,347
  • 3
  • 24
  • 36
5
votes
1 answer

Make QTreeView automatically resize to contents

I am trying to make a QTreeView automatically resize to its contents. This is my setup: I am trying to create a "smart" tool tip which is a QWidget with Qt.Tool | Qt.FramelessWindowHint as its WindowFlags, which works nicely. It contains a layout…
rainer
  • 6,769
  • 3
  • 23
  • 37
5
votes
2 answers

Qt model/view vs standard widget

I am currently reading model/view tutorial from Qt, but I am still not sure if I should use model/view or widget for my Qt program : I need to do a logger application that will monitor all information in a simulation environment. Basic scenario…
peterphonic
  • 951
  • 1
  • 19
  • 38
5
votes
2 answers

How to disable the double click file renaming behavior on QTreeView and QFileSystemModel in PyQt?

Simple question. I'd like to use F2 or Enter for rename, and double click to open a file. Using self.treeView.doubleClicked.connect(self.doubleclick) I can do things in my self.doubleClick method, but the renaming is still triggered. The model is…
iacopo
  • 663
  • 1
  • 7
  • 22