qtreeview

QTreeView: checking if item to be dropped is already present and avoid it on dropEvent()

微笑、不失礼 提交于 2020-02-07 00:06:27
问题 I have a QTreeView with implemented dropEvent()-handler. If the item to be dropped is already existing under the target-root, how could I avoid the dropping at all? E.g. drag "user_b" from the "Master Data" Node on the node "Security Model"/"client_c"/"stakeholder_d" which already exists. Full working code example: #!/usr/bin/env python3 # coding = utf-8 from PyQt5 import QtWidgets, QtCore, QtGui TXT_CLIENT = "Clients" TXT_STAKEHLD = "Stakeholders" TXT_USER = "Users" TXT_SYSTEM = "Master Data

QTreeView: checking if item to be dropped is already present and avoid it on dropEvent()

ぃ、小莉子 提交于 2020-02-07 00:06:12
问题 I have a QTreeView with implemented dropEvent()-handler. If the item to be dropped is already existing under the target-root, how could I avoid the dropping at all? E.g. drag "user_b" from the "Master Data" Node on the node "Security Model"/"client_c"/"stakeholder_d" which already exists. Full working code example: #!/usr/bin/env python3 # coding = utf-8 from PyQt5 import QtWidgets, QtCore, QtGui TXT_CLIENT = "Clients" TXT_STAKEHLD = "Stakeholders" TXT_USER = "Users" TXT_SYSTEM = "Master Data

How can I efficiently expand an entire subtree of a QTreeView?

女生的网名这么多〃 提交于 2020-02-05 13:57:38
问题 EDIT: it turns out that the root performance problem was a size-to-fit function attached to the expanded() signal, so I'm going to accept the first answer and delete this question for being misleading. Note: I'm asking this question so I can provide an answer for it (and maybe get a better answer). The solution is not intuitive. MacOS builds of Qt may have a way for the user to expand an entire QTreeView subtree (there was an open bug for it) but non-MacOS builds definitely do not. I am

How can I efficiently expand an entire subtree of a QTreeView?

人走茶凉 提交于 2020-02-05 13:57:15
问题 EDIT: it turns out that the root performance problem was a size-to-fit function attached to the expanded() signal, so I'm going to accept the first answer and delete this question for being misleading. Note: I'm asking this question so I can provide an answer for it (and maybe get a better answer). The solution is not intuitive. MacOS builds of Qt may have a way for the user to expand an entire QTreeView subtree (there was an open bug for it) but non-MacOS builds definitely do not. I am

How to display parent directory in tree view?

戏子无情 提交于 2020-01-30 08:50:11
问题 In my application I have a QTreeview. I have a folder named "test" that contains many subfolders. The treeview only shows the subfolders not the test forlder it self! def create_treeview(self): self.treeView = QTreeView() self.treeView.setMinimumSize(QSize(250, 0)) self.treeView.setMaximumSize(QSize(250, 16777215)) self.treeView.setObjectName("treeView") self.dirModel = QFileSystemModel() self.dirModel.setRootPath(QDir.rootPath()) self.dirModel.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)

Create a QModelIndex from a Data Item

試著忘記壹切 提交于 2020-01-15 23:54:09
问题 I'm looking for a way to create a QModelIndex from a particular piece of data in my model. I can go from a QModelIndex to a data item via: CustomData *data = static_cast<CustomData *>(modelIndex.internalPointer()); But I'm looking for an inverse function to go from: QModelIndex *index = createIndex(data); // ?? I've implemented linkages between my data very similar to the simple tree model example (http://doc.qt.io/qt-5/qtwidgets-itemviews-simpletreemodel-example.html). My view displays the

python/pyside using a custom widget in a qtreewidget

别说谁变了你拦得住时间么 提交于 2020-01-15 11:38:09
问题 Using Python3 and pyside. I have a python dictionary which I want to display as a tree using Qt. I want the values to be editable but not the keys. I have managed to achieve this using setItemWidget as shown in the following example: #!/usr/bin/python3 # -*- coding: utf-8 -*- import sys from PySide import QtGui def data_to_tree(parent, data): if isinstance(data, dict): parent.setFirstColumnSpanned(True) for key,value in data.items(): child = QtGui.QTreeWidgetItem(parent) child.setText(0, key)

How to remove QTreeView indentation

拜拜、爱过 提交于 2020-01-13 16:27:25
问题 I want to have a QTreeView without an indentation on the left side increasing at each nesting level. I tried setting QTreeView::setIndentation(0) . It removes the indentations just as I want, however it also hides the tree arrows. Default behavior: With indentations ✗ With arrows ✔ After setIndentation(0) : Without indentations ✔ Without arrows ✗ Desired behavior: Without indentations ✔ With arrows ✔ So how can I achieve the result shown in the third example? Is there any standard way of

How to remove QTreeView indentation

帅比萌擦擦* 提交于 2020-01-13 16:27:18
问题 I want to have a QTreeView without an indentation on the left side increasing at each nesting level. I tried setting QTreeView::setIndentation(0) . It removes the indentations just as I want, however it also hides the tree arrows. Default behavior: With indentations ✗ With arrows ✔ After setIndentation(0) : Without indentations ✔ Without arrows ✗ Desired behavior: Without indentations ✔ With arrows ✔ So how can I achieve the result shown in the third example? Is there any standard way of

QFileSystemModel and QTreeView - strange behavior when resetting view

妖精的绣舞 提交于 2020-01-06 08:14:18
问题 I wrote this on official forums of Qt, but it seems dead, so I am going to copy-paste it here. I am writing small program for copying files. I use QTreeView and I have inherited from QFileSystemModel , so I was able to add checkboxes to every row in the QTreeView . I also use setNameFilters method connected with QLineEdit , so user can specify what file extensions he wants to display in the QTreeView . I have spotted the following behavior: 1) When I run the program and enter extensions to