qfilesystemmodel

QFileSystemModel QTableView Date Modified highlighting

て烟熏妆下的殇ゞ 提交于 2021-02-16 20:54:06
问题 I am trying to make a little file browser using QFileSystemModel and QTableView. I was wondering if it is possible to highlight rows with same value in "Date Modified" column, for instance if I have two or more files which been modified today row gets highlighted in green, those modified yesterday highlighted in green but lighter shade, etc. 回答1: To change the background color there are several options such as: override the data() method of the model so that the return value associated with

Using QFileSystemModel with ListView

本秂侑毒 提交于 2021-02-07 19:04:58
问题 I'm trying to create a simple ListView that I can use to browse the file system, using QFileSystem . First, I tried to use code I've found that worked for QDirModel: main.qml: ListView { id: list width: 300 height: 500 model: DelegateModel { model: myFileModel delegate: Text{ id: txt text: fileName MouseArea { anchors.fill: parent onClicked: { //Switch directory when clicked list.model.rootIndex = list.model.modelIndex(index); } } } } main.cpp: int main(int argc, char *argv[]) { QApplication

Qt File Browser based on QML

亡梦爱人 提交于 2021-02-07 07:21:52
问题 It is easy to implement a file browser by using QFileSystemModel. But the listview UI is not pretty. So I want to implement a file browser using QML. the QML has model/view support. But how to display the filesystem tree in QML? Any clue would be appreciated. 回答1: Since Qt5.5 we have TreeView QML component available, main.qml : import QtQuick.Controls 1.4 TreeView { anchors.fill: parent TableViewColumn { title: "Name" role: "fileName" width: 300 } model: my_model } main.cpp : QFileSystemModel

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

How to display parent directory in tree view?

戏子无情 提交于 2020-01-30 08:50:11
问题 In my application I have a QTreeview. I have a folder named "test" that contains many subfolders. The treeview only shows the subfolders not the test forlder it self! def create_treeview(self): self.treeView = QTreeView() self.treeView.setMinimumSize(QSize(250, 0)) self.treeView.setMaximumSize(QSize(250, 16777215)) self.treeView.setObjectName("treeView") self.dirModel = QFileSystemModel() self.dirModel.setRootPath(QDir.rootPath()) self.dirModel.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)

Why my QFileSystemModel QModelIndex couldn't get child node infomation?

Deadly 提交于 2020-01-16 14:03:13
问题 I am learn about Model/View architecture in pyqt, but when i follow the Using model indexes instruction and try to write a demo in pyqt5 style.The QModelIndex couldn't get child node information? The code: class DemoB(QPushButton): def __init__(self): super().__init__() self.clicked.connect(self.on_clicked) def on_clicked(self, checked): model = QFileSystemModel() model.setRootPath(QDir.homePath()) parentIndex = model.index(QDir.homePath()) print(parentIndex.data() ) print(parentIndex, model

QT - QFileSystemModel on server-client program

Deadly 提交于 2020-01-15 06:34:27
问题 I am working on a server-client QT project that allows to transfer files between server and client. Being a GUI project, I want to display the server's file system on client program, like a file explorer. The question is : is there a way to send the QFileSystemModel or QFileSystemWatcher from server to client, or to display the server's system file on client side? Thank you. 回答1: The best approach to tackle this problem is to implement a serialization technique for your object(s). Once that's

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

Why my QFileSystemModel QModelIndex couldn't get child node infomation?

橙三吉。 提交于 2019-12-28 07:06:25
问题 I am learn about Model/View architecture in pyqt, but when i follow the Using model indexes instruction and try to write a demo in pyqt5 style.The QModelIndex couldn't get child node information? The code: class DemoB(QPushButton): def __init__(self): super().__init__() self.clicked.connect(self.on_clicked) def on_clicked(self, checked): model = QFileSystemModel() model.setRootPath(QDir.homePath()) parentIndex = model.index(QDir.homePath()) print(parentIndex.data() ) print(parentIndex, model