[PyQt] Dumb question about QDirModel / setModel
Nicolas Girard
nicolas.girard at nerim.net
Mon Sep 17 16:28:34 BST 2007
Hi,
could someone tell me why this works...:
#!/usr/bin/python
from PyQt4 import QtGui
import sys
class Window(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.tree = QtGui.QTreeView(self)
def setModel(self,model):
tree=self.tree
tree.setModel(model)
tree.resize(640, 480)
if __name__=="__main__":
app=QtGui.QApplication(sys.argv)
window=Window()
model = QtGui.QDirModel()
window.setModel(model)
window.show()
sys.exit(app.exec_())
... whereas this doesn't...?
#!/usr/bin/python
from PyQt4 import QtGui
import sys
class Window(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.tree = QtGui.QTreeView(self)
model = QtGui.QDirModel()
self.setModel(model)
def setModel(self,model):
tree=self.tree
tree.setModel(model)
tree.resize(640, 480)
if __name__=="__main__":
app=QtGui.QApplication(sys.argv)
window=Window()
window.show()
sys.exit(app.exec_())
Many thanks in advance,
cheers,
Nicolas
More information about the PyQt
mailing list