qtreeview

(PyQt) QTreeView - want to expand/collapse all children and grandchildren

此生再无相见时 提交于 2019-12-08 07:56:34
问题 I want to be able to expand or collapse all children of a particular branch in a QTreeView. I am using PyQt4. I know that QTreeView's have an expand all children feature that is bound to *, but I need two things: It needs to be bound to a different key combination (shift-space) and I also need to be able to collapse all children as well. Here is what I have tried so far: I have a subclass of a QTreeView wherein I am checking for the shift-space key combo. I know that QModelIndex will let me

QAbstractItemModel and QTreeView [closed]

拟墨画扇 提交于 2019-12-07 01:35:34
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I need working examples (c++) of show own data model in QtreeView. 回答1: There's a pretty good QTreeView/QAbstractItemModel example here. It's fairly straightforward once you get used to QT's ultra-generic model..

(PyQt) QTreeView - want to expand/collapse all children and grandchildren

纵饮孤独 提交于 2019-12-06 16:15:27
I want to be able to expand or collapse all children of a particular branch in a QTreeView. I am using PyQt4. I know that QTreeView's have an expand all children feature that is bound to *, but I need two things: It needs to be bound to a different key combination (shift-space) and I also need to be able to collapse all children as well. Here is what I have tried so far: I have a subclass of a QTreeView wherein I am checking for the shift-space key combo. I know that QModelIndex will let me pick a specific child with the "child" function, but that requires knowing the number of children. I am

QTreeView with fixed column widths

邮差的信 提交于 2019-12-06 13:17:29
问题 Today I'm trying to configure a QTreeView to fit my requirements. My view has basically three columns. The second and third column should be exactly 50 pixels wide no matter, what might be widgets size. The first column should occupy the remaining space. If I enlarge my widget the first column should automatically occupy the need free space, whereas the second and third column should retain their given widths of 50 pixels. This is what I tried so far: main.cpp #include <QApplication> #include

Python object in QMimeData

落花浮王杯 提交于 2019-12-06 10:13:13
问题 I'm implementing drag and drop QTreeView based on my custom model. All works fine, my tree displays data, drag and drop is enabled and now the last step lies ahead of me - to drop and trasfer dragged data. To do this I need to implement mimeTypes, mimeData and dropMimeData methods in my model. And now my question: Is there any easy standard way how to pass an arbitrary Python object through QMimeData? I'm doing just an internal move within QTreeView which displays hierarchy of my Python

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

醉酒当歌 提交于 2019-12-06 06:31:39
问题 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 is not the case for me and I can't figure out the discreptency and how other people are not running into this issue. After debugging, I noticed that QFileSystemModel _q_fileSystemChanged slot which takes most of the time is still executed on the main

Highlight specific substrings in a QTreeView

不打扰是莪最后的温柔 提交于 2019-12-06 06:08:24
I want to highlight (or in general customise the formatting) of specific substrings appearing in a QTreeView in PyQt. To demonstrate what I mean, I have taken the example at PyQt4\examples\itemviews\dirview.pyw and manually added highlighting: Here all instances of the substring 'as' are highlighted, but in general it might not be a pattern match, I may actually want to be very specific. I know that this can be easily done to a QTextEdit as per this SO question , but that relied on moving around the textCursor which I don't believe exists for a QTreeView. Can this be easily done? 来源: https:/

Hyperlinks in QTreeView without QLabel

孤街浪徒 提交于 2019-12-06 05:46:38
问题 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 of items), and creating 1000s of QLabels is slow. The upside is that I can use a Delegate in my QTreeView to draw text that looks like hyperlinks. This is super fast. The problem now is that I need them to respond like hyperlinks (i.e. mouseover

How to display sub-rows of QAbstractItemModel in QTableView

不羁的心 提交于 2019-12-06 05:06:03
I have my own class that inherits from QAbstractItemModel which has tree structure. I use a couple of views, that display filtered data of this model, using classes derived from QSortFilterProxyModel. My model structure looks like this: root | -- A | |-A1 | |-A2 | |-A3 | -- B | |-B1 | |-B2 | ... and so on... Where A, B .... are "main rows" (children of the root), and A1, A2, ... B1, B2... are "children rows" - node rows appended to "main rows". Now, what I need to do is a QTableView that displays "children rows" only: A1 A2 A3 B1 B2 But filtering methods I found in QSortFilterProxyModel

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

喜你入骨 提交于 2019-12-05 22:49:29
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 | Qt::MoveAction Implemented on my custom model mimeType s to return a QStringList with text/uri-list Implemented on my custom model dropMimeData to handle the drop if it ever occurred. This is all I needed to get it working on a QTreeWidget . I've gone on to: Implemented flags to return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled; Nevertheless,