Hello,
I am very very confused with my problem.
When I launch a Python environment in a terminal, and I try to instanciate a
QFileSystemModel, I have a segmentation fault:
$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> from PyQt4.QtCore import *
>>> from PyQt4.QtGui import *
>>> model = QFileSystemModel()
>>> model.setRootPath(QDir.homePath())
Segmentation fault
However, and I really don't understand, the attached file works well !
Am I doing it completely wrong ?
Here is my pyqt informations :
Package: python-qt4
State: installed
Automatically installed: no
Version: 4.7.4-0ubuntu1
#!/usr/bin/python
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.filebrowser = FileBrowserWidget()
self.setCentralWidget(self.filebrowser)
self.resize(600, 500)
class FileBrowserWidget(QWidget):
def __init__(self, *args):
super(FileBrowserWidget, self).__init__(*args)
layout = QHBoxLayout()
self.dirModel = QFileSystemModel()
self.dirModel.setRootPath(QDir.homePath())
self.view = QListView()
self.view.setModel(self.dirModel)
self.view.setViewMode(QListView.IconMode)
self.view.setRootIndex(self.dirModel.index(QDir.homePath()))
self.view.setResizeMode(QListView.Adjust)
self.view.setSpacing(10)
self.view.setWordWrap(True)
layout.addWidget(self.view)
self.setLayout(layout)
if __name__ == "__main__":
app = QApplication(sys.argv)
mainWin = MainWindow()
mainWin.show()
app.exec_()
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt