[PyQt] Model/View

Sun Wukong sun.wukong at rx3.net
Thu Nov 8 16:29:49 GMT 2007


Hello,

I'm a PyQt newbie, trying to implement the following exemple
http://doc.trolltech.com/4.0/qt4-interview.html
in Python.

Unfortunatly, nothing appear in the window but its title.

Thanks for your help.
Sw

Here's my code :

import sys
from PyQt4 import QtGui
from PyQt4 import QtCore


class ZeTest(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        splitter = QtGui.QSplitter()
        model = QtGui.QDirModel()
        arbre = QtGui.QTreeView(splitter)

        arbre.setModel(model)
        arbre.setRootIndex(model.index(QtCore.QDir.currentPath()))

        QtCore.qDebug("Current Dir : " + str( QtCore.QDir.currentPath()))

        maliste = QtGui.QListView(splitter)
        maliste.setModel(model)
        maliste.setRootIndex(model.index(QtCore.QDir.currentPath()))

        maselection = QtGui.QItemSelectionModel(model)
        arbre.setSelectionModel(maselection)
        maliste.setSelectionModel(maselection)

        self.setWindowTitle("Two views onto the same directory model")


app = QtGui.QApplication(sys.argv)
t = ZeTest()
t.show()
app.exec_()


-- 
SunWukong

Linux User #354048
GPG Key available : 0xF4DD0AD2 on keyserver.ubuntu.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20071108/b67cc29e/signature.bin


More information about the PyQt mailing list