qtreeview

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

Qt: Sorting is wrong when using QSortFilterProxyModel on number strings and getting wrong column text

六月ゝ 毕业季﹏ 提交于 2019-12-30 07:14:09
问题 i have simple model view treeview with QSortFilterProxyModel proxy to sort the columns and QStandardItemModel as the model in each columns there are string that gets sorted fine but in columns that contains number ( as strings ) the sorting wrong . say i have 9,12,1 (each number in different column when i sort them im getting 1,12,9 or 12,1,9 but never in the right order . like 1,9,12 or 12,9,1 why ? also i notice that when i sort row by column , when i try to get the new column text with m

How to make item view render rich (html) text in Qt

和自甴很熟 提交于 2019-12-27 10:37:14
问题 Suppose my model has items with the following string for Qt::DisplayRole <span>blah-blah <b>some text</b> other blah</span> I want QTreeView (actually, any item view) to render it like a rich text. Instead, item views render it like a pure text by default. How to achieve the desired rendering? Actually, this is a search results model. User enters a text, some document is searched against that text and the user is presented with search results, where the words being searched should be bolder

PyQt5: Setting data for a QStandardItem

白昼怎懂夜的黑 提交于 2019-12-25 08:05:13
问题 If I construct a QStandardItem like so: item = QtGui.QStandardItem('Item Name') When this item is added to a QStandardItemModel model and is viewed in a QTreeView I get a cell that says Item Name . However, when I construct one like: item = QtGui.QStandardItem() item.setData(123) I get an an empty cell, but I can still recall the data by calling: print(item.data()) and I will get the number 123 . How can I get the number to actually display in the cell? 回答1: The argument passed to the

QFileSystemModel and QTreeView showing dirs only. How to hide expansion marks against the empty dirs?

天涯浪子 提交于 2019-12-24 15:57:39
问题 I'm building somewhat like standard file explorer - left pane is for folders tree, and the right one to display files within selected folder. QTreeView with QFileSystemModel is used to display folders. Model's filter is set to QDir::Dirs | QDir::NoDotAndDotDot to list dirs only, no files. I want to display expansion marks only against the folders with subfolders, i. e. if some dir is empty or contains only files, it shouldn't be expandable. But instead, tree view keeps expansion marks against

QTreeview does not update correctly when items are added to the root

帅比萌擦擦* 提交于 2019-12-24 11:28:47
问题 I've got a treeview, which should show the content of an own datacollection to achieve this, I've implemented a new model for the treeview. When I add an object to any parent Item everything works fine and the new Item is shown in the view, but when I try to add an item to the rootitem, this item does not show up until I add an Object to another parentitem or I reset the model. My method to add rows to the model looks like this: bool TreeModel::insertRows(int row, int count, const QModelIndex