qtreeview

Qt model/view vs standard widget

戏子无情 提交于 2019-12-12 14:46:55
问题 I am currently reading model/view tutorial from Qt, but I am still not sure if I should use model/view or widget for my Qt program : I need to do a logger application that will monitor all information in a simulation environment. Basic scenario might be : User 1 say something to virtual entity B (logger application get what user 1 said and show it in table view or list view) Virtual entity B reply something to user 1 (logger application get what user 1 said and add it in table view or list

QAbstractItemModel: annoying branch line in QTreeView

此生再无相见时 提交于 2019-12-12 02:12:53
问题 I've made a minimalistic subclass of QAbstractItemModel . It works, but in QTreeView there is a odd branch line that should not appear here (because there is no more items after [Sensor arrays] section). Cannot you tell me, what have I done wrong and how to fix it? Here is my code: import os, sys from PyQt5 import QtCore, QtGui, QtWidgets import treelib class BlockHierarchyNode(object): def __init__(self, icon_path=None, name="", description="", is_category=False): if icon_path is not None:

How can I get a PyQt slot to update the QTreeView during the slot?

て烟熏妆下的殇ゞ 提交于 2019-12-11 18:29:03
问题 So I've been starting to contribute code to uPyLoader on github (https://github.com/BetaRavener/uPyLoader) and this app has a compile button. When the compile button is clicked, it's connected to a slot called compile_files. Here is that code with a few of my modification attempts(in main.py if you're wanting to see the whole file). The problem I'm trying to solve is that when you compile foo.py it creates foo.mpy and if foo.mpy already exists then you can't really tell if the compile did

Not able to see plus sign even if I pass true from hasChildren function in Qt

情到浓时终转凉″ 提交于 2019-12-11 18:24:10
问题 I am implementing tree view, I have sub classed my model and view. initially I am populating all the top level items and I don't know how many child's are there for each top level items but I know all the top level items has a child's, so I have re-implemented hasChildren() function and pass true for all the top level items, but I am not able to see + sign for the top level items even i pass true. Please let me know the problem Thanks in advance. 来源: https://stackoverflow.com/questions

Delegate erasing text in QTreeView using QStandardItemModel

☆樱花仙子☆ 提交于 2019-12-11 18:12:46
问题 I'm having some difficulty adding a delegate to my QTreeView. I have added some QStandardItems through a model which works fine, but when I add the delegate, the text is erased and only the icons are visible. This is the code i'm using for my delegate: void SeqNavDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.column() == 0 && option.state & QStyle::State_Enabled) { const QIcon icon(QLatin1String(":/SeqNavMenu/images/green.png

pyqt5: Properly update QTreeView after data change on the database

我与影子孤独终老i 提交于 2019-12-11 17:35:32
问题 I have a model-based QTreeView which is fed by a QSortFilterProxyModel. I am displaying rows from the database here. With a double-click I am executing a modal QDialog to edit the data (the user can do CRUD operations like create new rows into my SQLite data base, updates, delete etc.). On closing the edit-dialog the focus gets back to the underlying QTreeView. Now I would like to refresh the changed data from the database. One way to do this would be to build up my complete model and refetch

QTreeview with my model how to implement copy paste operation

扶醉桌前 提交于 2019-12-11 09:51:07
问题 I want to implement copy and paste operation in my QTreeView against my context menu copy and paste I have subclass QAbstractItemModel. I have Treeview Say Four Tope level items and each of them are having multiple child Top Item1 ---------- Child1 Child11 Child111 Top Item2 ---------- Top Item3 I want to right on click item "child1" and copy child1 and all its child up to child111 and then right click and paste on "Top Item3" so that all items from child1 to child111 is copied under Top

QTreeView: maintaining mapping between QModelIndex and underlying data

帅比萌擦擦* 提交于 2019-12-11 08:56:12
问题 I have problems migrating from QTreeWidget to QtreeView . Things that were obvious and trivial with QTreeWidget seem to be impossible with view. Specifically: I have a main window with a treeview in it. TreeView uses the model I've implemented, but not directly – through QSortFilterProxyModel that is set as a tree's model. Now, the user activates an item in the tree and main windows receives a signal itemActivated(QModelIndex item) . How can I tell which item of the underlying data was

Passing a variable to other dialog Qt

本小妞迷上赌 提交于 2019-12-11 07:40:51
问题 I have a QTreeView with a list of text files. If a file is selected and void FileList_dialog::on_openButton_released() it should pass a variable path to dialog textFile_dialog . Until now I've this: void FileList::on_openButton_released() { QModelIndex index = ui->treeView->currentIndex(); QFileSystemModel *model = (QFileSystemModel*)ui->treeView->model(); QString path = model->filePath(index); QString name = model->fileName(index); QString dir = path; QFile file(path); qDebug() << path;

How to reenable manual column layout in a QTreeView with QSortFilterProxyModel

不想你离开。 提交于 2019-12-11 06:46:12
问题 I have a QTreeView which displays data from a SQLite database. The QTreeView has filters and sorting enabled. For filtering I display a QLineEdit into the column header. Problem: the column layout seems to be fixed by the modifications in order to enable the QLineEdit filtering. Question: Is there a way to reenable the arrangement of the column layout - via dragging the columns, as it is in the standard QTreeView layout. I want the user to be able to rearrange his columns the desired way.