qfilesystemmodel

QFileSystemModel custom icons?

ぃ、小莉子 提交于 2019-12-01 10:59:58
In my project, I have a QTreeView displaying a location on my drive. I need to change all the icons of the files to a custom icon but leave the folders alone. I reimplemented QFileSystemModel and I was able to change ALL the icons. Any way to limit the change to only files instead of folders? QVariant MyQFileSystemModel::data(const QModelIndex& index, int role) const { if(role == Qt::DecorationRole) return QPixmap(":/icons/TAG_Int.png"); return QFileSystemModel::data(index, role); } This: Becomes: How can I only change the icon of the files? Thanks for your time :) I answered my own question:

QFileSystemModel custom icons?

眉间皱痕 提交于 2019-12-01 09:15:24
问题 In my project, I have a QTreeView displaying a location on my drive. I need to change all the icons of the files to a custom icon but leave the folders alone. I reimplemented QFileSystemModel and I was able to change ALL the icons. Any way to limit the change to only files instead of folders? QVariant MyQFileSystemModel::data(const QModelIndex& index, int role) const { if(role == Qt::DecorationRole) return QPixmap(":/icons/TAG_Int.png"); return QFileSystemModel::data(index, role); } This:

How to Display List of Files in A specified directory

 ̄綄美尐妖づ 提交于 2019-12-01 00:15:23
How to display in a ListView manner files in a directory specified in the code in a PyQt window example : Like in the right pane of this QFileSystemModelDialog app You have to create 2 QFileSystemModel , one will show the directories and the other the files. To change the view of the QListView you must use the clicked signal, using the QModelIndex you set the new rootIndex . import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import * class Widget(QWidget): def __init__(self, *args, **kwargs): QWidget.__init__(self, *args, **kwargs) hlay = QHBoxLayout(self) self.treeview = QTreeView()

How to Display List of Files in A specified directory

自古美人都是妖i 提交于 2019-11-30 18:07:50
问题 How to display in a ListView manner files in a directory specified in the code in a PyQt window example : Like in the right pane of this QFileSystemModelDialog app 回答1: You have to create 2 QFileSystemModel , one will show the directories and the other the files. To change the view of the QListView you must use the clicked signal, using the QModelIndex you set the new rootIndex . import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import * class Widget(QWidget): def __init__(self,

How to create custom icons for QFileSystemModel in a background thread

為{幸葍}努か 提交于 2019-11-30 05:32:05
问题 I am making a file browser in qt for some custom design-files. I want to load their preview as their thumbnail and for that reason I am using QIconProvider to return the Icon to my QFileSystemModel . The problem is that the algorithm that creates the QIcon needs some resources and as a result my application is not responsive until it finishes loading all the thumbnails. I am wondering if there is any way to put my QIconProvider in a background thread, so that I have my application responsive.

Python PyQt QFileSystemModel Root Path

给你一囗甜甜゛ 提交于 2019-11-28 07:55:40
问题 This is the code i have to display a tree view of a directory called "C:\Myfolder". import sys from PyQt4 import QtGui,QtCore class Myview(QtGui.QMainWindow): def __init__(self,parent=None): QtGui.QMainWindow.__init__(self) model = QtGui.QFileSystemModel() model.setRootPath('C:\Myfolder') view = QtGui.QTreeView() view.setModel(model) self.setCentralWidget(view) if __name__ == '__main__': app = QtGui.QApplication(sys.argv) myview = Myview() myview.show() sys.exit(app.exec_()) Even though i set