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

How to remove the empty space at the left of a QTreeView

I have a subclassed QTreeView. I need to make it looks like simple QListView without space (left corner spacing) for child items. What should I do? Qt is 4.7.4. Already tried setRootIsDecorated and it doesn't help. I have tried…
cassandrad
  • 3,412
  • 26
  • 50
4
votes
2 answers

How to Get Absolute Path of Currently Selected Item in QTreeView

I have a simple QTreeView with a QFileSystemModel pointing to the root directory: #include "mainwindow.h" #include #include #include #include #include int main(int argc,…
sj755
  • 3,944
  • 14
  • 59
  • 79
4
votes
1 answer

QTreeView with custom items

I'm writing my first Qt application with PySide and am having some trouble creating a custom tree view. I'd like to list my own data in one column. Each item must have text with tooltip, different text color, different background color, icons with…
userwedi
  • 111
  • 1
  • 1
  • 4
4
votes
1 answer

To set widgets on children items on QTreeView

Thanks to this thread, I'm able to add widgets to 2nd or later column of QAbstractItemView (in my example QTreeView) of top level items of a view. But is it possible to add widgets to the children items? Here's what I've tried which partly went…
IsaacS
  • 3,551
  • 6
  • 39
  • 61
4
votes
2 answers

How to know exactly when a user expands a QTreeView item?

Is there a way to know exactly when an expand operation begins when a user, lets say clicks the expand arrow in a QTreeView? For the case when he double clicks I can catch the double-click event. I tried reimplementing this slot void expand(const…
GlassFish
  • 14,851
  • 3
  • 17
  • 22
4
votes
1 answer

Qt proxy model usage example

I am using a Qt 4's QFileSystemModel and QTreeView. I am writing a Windows Explorer like file manager, and want to make a tree more similar to Windows', where tree consist some shortcut paths like Desktop, My Documents. The only thing I want is to…
4
votes
1 answer

PyQt4: Display QtSql database in QTreeWidget

How would you display the contents of a QtSql table using a QTreeWidget? There isn't quite enough information around this particular subject...
user1006989
4
votes
2 answers

Checkboxes in treeview update slowly

I implemented a cutom model for treeview for having checkboxes inside the treeview. If I check a parent node all child nodes should be chekced automatically. This basically works but der is a time lack between checking the parent node and updating…
Razer
  • 7,843
  • 16
  • 55
  • 103
4
votes
2 answers

minimal example qtreeview for pyqt and the qt designer

I am trying to get a minimal example for an application designed by the qt designer with pyqt involving a QTreeView to work 1) i can start the app this way but if i push the butten, no entry in the TreeView widget is shown, i do not get any error…
thafritz
  • 449
  • 1
  • 6
  • 8
4
votes
1 answer

style not working with QItemDelegate

I have a QTreeview and I used this stylesheet QTreeView#treeView::item:selected:active { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc); } QTreeView#treeView::item:hover { background:…
mrbm
  • 1,136
  • 1
  • 12
  • 36
3
votes
2 answers

QTreeView vs setIndexWidget

I am using QStandardItemModel with QStandardItem's. I don't want to write my own model and any delegates. I just want to have tree of checkboxes with QComboBox'es in second column... m_model->setColumnCount(2); for (int i = 0; i < sectionCount;…
k06a
  • 17,755
  • 10
  • 70
  • 110
3
votes
2 answers

How to enable/disable a item in a QTreeView eventbased?

I want to enable/disable a checkable item in a QTreeWidget, when a specific signal is sent. The following code dows not work: model = QStandardItemModel() view = QTreeView() view.setModel(model) rootItem = QStandardItem() rootItem =…
leviathan
  • 363
  • 3
  • 10
3
votes
2 answers

How to show only folders with specific files using QTreeView and QFileSystemModel?

I have a problem filtering specific folder using QTreeView and QFileSystemModel. I set my root QFileSystemModel to a specific folder - this works. But I want to show just folders that contain .jpg files. Is this possible? I filter .jpg files and…
Adriano Leal
  • 316
  • 1
  • 5
  • 20
3
votes
1 answer

QTreeView / QFileSystemModel: How do I limit tree depth?

I have a QTreeView with a QFileSystemModel as its model. I can't figure out how to limit the depth of the tree. I would have thought it would be a function of the model? What I mean is, if I set the depth to 1, for example, only the top level items…
3
votes
1 answer

Qt custom tree model of nested vector

I've got a nested data structure I'd like to display with a QTreeView. Let's say I've got something like this: class Image { public: ... std::vector filter_; }; typedef std::vector Gallery; typedef std::vector
P3trus
  • 6,747
  • 8
  • 40
  • 54