qtreeview


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

QTreeView: setting icon for item on dropEvent()

耗尽温柔 提交于 2020-01-06 04:30:47
问题 I have a QTreeView class and want to set an icon on the dropEvent() event. See the following example: See the icon for the parent "Users" under the first root "Master Data". I want to drag a user (e.g. "user_a") under the second root "Security Model" under "client_c"/"stakeholder_d" and the user_a should get the same icon as the group (already the case for existing "user_b"). #!/usr/bin/env python3 # coding = utf-8 from PyQt5 import QtWidgets, QtCore, QtGui TXT_CLIENT = "Clients" TXT_STAKEHLD

QTreeView with columns

拥有回忆 提交于 2020-01-05 10:28:47
问题 I have these messages received on the can bus which need to be displayed on a suitable Qt Widget (Please refer attached picture). It seems I can use QTreeView for it. I need to show a tree which contains many messages as shown in attached picture. Each row will contain information about the received message. It should consist of columns : Length Time of receiving Message ID Name of the message Message content and when I expand message it should its different signals. How can I make a

qt: I would like to disable the key bindings automatically set for a QTreeView

丶灬走出姿态 提交于 2020-01-04 05:17:59
问题 I am using PyQt4 and a QTreeView (although this could just as easily apply to qt directly). Right now there are default key bindings that control the expanding/collapsing of branches using the right and left arrows. Unfortunately, these bindings are not ideal and I would like to disable them. I have not been able to figure out how to do that. Does anyone know how to disable (or reassign) the default key bindings on a QTreeView? 回答1: There are two possible options for you: 1) Reimplement the

QTreeView remove decoration/expand button for all items

最后都变了- 提交于 2020-01-02 02:44:07
问题 I want to have my QTreeView always expanded all of the items. In that case, all expand button / decoration are unnecessary and I want get rid of them. How can I delete all of them? setRootIsDecorated will only delete that buttons on first level... 回答1: This is what I've done in the past for this problem, it's a bit of a hack but it's worked pretty well. In this case none.png doesn't exist. treeView->setStyleSheet( "QTreeView::branch { border-image: url(none.png); }" ); 回答2: See https://forum

Adding Vertical headers to a QTreeView

大兔子大兔子 提交于 2020-01-01 17:10:46
问题 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 horizontal headers (setHorizontalHeader()), QTreeView only allows a single header (setHeader()). I know that I can just pretend that the leftmost column is the header and render it with a different background color (I don't need the ability to

工具导航Map