qtreeview

TreeView in Python+QT

家住魔仙堡 提交于 2021-02-18 08:37:28
问题 I need to make a treeView with 4 columns with a checkbox in the first column. I have made ​​the tree view, just that I do not put the checkbox in the first column. I tried but it gets me in every position (row, column ) ........... Here is my code: import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from copy import deepcopy from cPickle import dumps, load, loads from cStringIO import StringIO class myNode(object): def __init__(self, name, state, description,otro, parent=None

How can I load a CSV file into a QTreeView?

*爱你&永不变心* 提交于 2021-02-11 06:29:29
问题 Note: I am a complete beginner. I am using a pandas dataframe to import a csv file that I converted from the following table. I need to load the csv file into a QTreeView and have been unable to do so. The output format should be: I will have to retrieve the "Scale Type" at some point, so I would like to somehow tag it to that item, but I'm not sure if that is possible. I have tried converting my data into a pandas dataframe and loading; loading the data directly with a csv; and converting it

How does QAbstractItemModel Represent Tree?

别等时光非礼了梦想. 提交于 2021-02-07 20:15:49
问题 I'm still having a great deal of difficulty understanding QAbstractItemModel's representation of items. There are two methods that return QModelIndex items that just aren't making any sense to me. QModelIndex QAbstractItemModel::index(int row, int column, const QModelIndex& index) is the first. What is the view passing to this function? I index the specific tree item to have an index created for? If so, what's the point of the function? Why not just return index? What do row and column

How does QAbstractItemModel Represent Tree?

ⅰ亾dé卋堺 提交于 2021-02-07 19:59:43
问题 I'm still having a great deal of difficulty understanding QAbstractItemModel's representation of items. There are two methods that return QModelIndex items that just aren't making any sense to me. QModelIndex QAbstractItemModel::index(int row, int column, const QModelIndex& index) is the first. What is the view passing to this function? I index the specific tree item to have an index created for? If so, what's the point of the function? Why not just return index? What do row and column

Add additional information to items in a QTreeView/QFileSystemModel

北战南征 提交于 2021-01-28 08:53:28
问题 I would like to render each item in a QTreeView differently based on a number of attributes stored in a database and based on whether the item is a folder or a file. However, I don't understand how the QTreeView or QFileSystemModel communicate with the delegate. Whenever an item must be drawn, including during initialization, I'd expect to provide the delegate with all the parameters it requires and then use a series of if statements within the delegate to set how the particular item is drawn

QTreeView with QFileSystemModel is not working properly

…衆ロ難τιáo~ 提交于 2021-01-28 05:08:27
问题 I set QFileSystemModel root path and then set it as QTreeView model, but if I try to find index of a speciffic file it is giving me D: I am sure the file is there ! self.model = QtWidgets.QFileSystemModel() self.model.setNameFilters(['*.ma']) self.model.setFilter(QtCore.QDir.Files)#QtCore.QDir.AllDirs | QtCore.QDir.NoDotAndDotDot | QtCore.QDir.AllEntries) self.model.setNameFilterDisables(False) self.model.setRootPath(path) self.tree_local_file.setModel(self.model) self.tree_local_file

QTreeView Horizontal Scrollbar problems

冷暖自知 提交于 2021-01-02 07:18:34
问题 I've a problem with QTreeView horizontal scrollbar, it doesn't appear. I've set horizontal scrollbar policy to ScrollBarAsNeeded, but it doesn't appear if needed. Have tried to connect expanded and collapsed signals to a slot: connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex))); connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex))); The slot consists of one line of code: update_scroll_area(const QModelIndex& i) {

QTreeView Horizontal Scrollbar problems

﹥>﹥吖頭↗ 提交于 2021-01-02 07:14:18
问题 I've a problem with QTreeView horizontal scrollbar, it doesn't appear. I've set horizontal scrollbar policy to ScrollBarAsNeeded, but it doesn't appear if needed. Have tried to connect expanded and collapsed signals to a slot: connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex))); connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex))); The slot consists of one line of code: update_scroll_area(const QModelIndex& i) {

QTreeView Horizontal Scrollbar problems

纵饮孤独 提交于 2021-01-02 07:14:00
问题 I've a problem with QTreeView horizontal scrollbar, it doesn't appear. I've set horizontal scrollbar policy to ScrollBarAsNeeded, but it doesn't appear if needed. Have tried to connect expanded and collapsed signals to a slot: connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex))); connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(update_scroll_area(QModelIndex))); The slot consists of one line of code: update_scroll_area(const QModelIndex& i) {

Filter model items in tree view

浪子不回头ぞ 提交于 2020-04-16 05:49:43
问题 I have a model class: class ItemModel : public QAbstractItemModel { Q_OBJECT public: enum ItemRoles { ItemRole = Qt::UserRole + 1, NameRole, IdRole, FilterRole // To be used in filtering }; QVariant data(const QModelIndex &index, int role) const; } Model returns data according to roles: QVariant ItemModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); Item *item = itemFromIndex(index); switch (role) { case ItemRole: return QVariant::fromValue(item);