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
1 answer

Insert and delete rows in QTreeView

Good day, I Have base model inherited from QAbstractItemModel, and some background threads which notify this model from time to time, in examples the insertions rows implemens somthing like this bool TreeModel::insertRows(int position, int rows,…
Topilski Alexandr
  • 669
  • 1
  • 12
  • 34
4
votes
1 answer

How to add custom row in QFileSystemModel?

I am using QFileSystemModel to represent file structure through the QTreView. Everything works fine, but I need to add an additional row at some level of the tree. For example for now is: -root --row1 --row2 --row3 All these rows mapping…
v-odin
  • 53
  • 6
4
votes
1 answer

Qt: Example of QAbstractItemModel implementation using QtSql (to use with QTreeView)

I'm looking for an example implementation of QAbstractItemModel to use with QTreeView. The model should load data from QSqlQuery and should do it in a "lazy" way. In other words I only want to load records for nodes/parents that are open. And I'd…
user666491
4
votes
2 answers

QAbstractItemModel + QTreeView what could couse item to become unselectable?

I'm trying to create my own model based on QAbstractItemModel. It seems to work fine. It passes modeltest assertions. I've this strange problem when I remove a row. Removal operation works ok. But then other rows become unselectable (not all of…
user666491
4
votes
1 answer

QTreeView / QAbstractItemModel - adding items and using beginInsertRows

I'm implementing my model based on QAbstractItemModel and I'm using it with QTreeView to display hierachical data. Data are stored in sqlite table. My question is how should I call beginInsertRows when adding subnodes. Lets say I have some parent…
user666491
4
votes
2 answers

Qt what needs to be done for a custom model to enable drop?

I'm trying to enable drop on a custom model I have hooked up to QTreeView. I've done the following: Ensured that acceptDrops is enabled on the QTreeView Implemented on my custom model supportedDropActions to return Qt::CopyAction |…
Nantucket
  • 1,647
  • 3
  • 14
  • 25
4
votes
3 answers

Hyperlinks in QTreeView without QLabel

I'm trying to display clickable hyperlinks in my QTreeView. I was able to do this using QLabels and QTreeView.setIndexWidget per the recommendations from this question. Hyperlinks in QTreeView Unfortunately, my QTreeView can be rather large (1000s…
user297250
4
votes
3 answers

Add QCombobox inside QTreeview specific cell

I was trying to insert a QCombobox only in some specific cells of my QTreeview. As I read, I think that I need to create my delegate (that I've created). But I don't understand how to insert this in my treeview. I want to realize this: This is my…
Tex'N'Duet
  • 301
  • 2
  • 13
4
votes
1 answer

PyQt5: How to generate a QTreeView from a list of dictionary items?

I have a dataset like this: [{'level': 0, 'dbID': 77, 'parent_ID': 6, 'short_name': '0:0:0: to 6', 'long_name': '', 'order': 1, 'pos': 0} , {'level': 1, 'dbID': 88, 'parent_ID': 77, 'short_name': '1:1:1:Store13', 'long_name': '', 'order': 2,…
4
votes
1 answer

How do I set item delegates for multiple columns in a model that is processed by a proxy model?

I set my item delegates like so: COMBOBOX_ITEMS_FRUITS = ['Apple', 'Banana'] COMBOBOX_ITEMS_COLORS = ['Red', 'Green', 'Blue'] self.treeview.setItemDelegateForColumn(COLUMN_A,…
FatHippo
  • 177
  • 3
  • 12
4
votes
1 answer

How to show custom widgets in QTreeView?

I want to implement something like this: Show combobox/line edit or checkbox in second column as wish. Anyone know how to do this ??
Samuel
  • 127
  • 7
4
votes
1 answer

qt: pyqt: QTreeView internal drag and drop almost working... dragged item disappears

I almost have a completely working drag and drop re-order within a QTreeView. Everything seems to be ok except the dropped object never appears (though I can reference it numerous different ways that proves to me that it actually exists where it…
bvz
  • 869
  • 3
  • 13
  • 25
4
votes
1 answer

How does QAbstractItemModel Represent Tree?

I'm still having a great deal of difficulty understanding QAbstractItemModel's representation of items. There are two methods that return QModelIndex items that just aren't making any sense to me. QModelIndex QAbstractItemModel::index(int row, int…
SixDegrees
  • 781
  • 1
  • 8
  • 19
4
votes
2 answers

python emit signal on clicked QTreeview item checkbox changed

How can I emit a signal when the checkbox of a treeview item is changed? import sys from PySide import QtGui, QtCore class Browser(QtGui.QDialog): def __init__(self, parent=None): super(Browser, self).__init__(parent) …
JokerMartini
  • 5,674
  • 9
  • 83
  • 193
4
votes
1 answer

QT: QFileSystemModel _q_fileSystemChanged slot is executed on the UI thread which contradicts documentation

My UI is using QTreeView with QFileSystemModel to be able to select folders and files. The documentation for QFileSystemModel says that file structure update is done on a seperate thread which would mean the UI would not be blocked. However, this…