[PyQt] Model/View
Mark Summerfield
mark at qtrac.eu
Thu Nov 8 16:52:08 GMT 2007
On 2007-11-08, Sun Wukong wrote:
> 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
If you add the line of code as shown below, the splitters will at least
show up. I think there's more to do though...
>
> 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.setCentralWidget(splitter)
>
> self.setWindowTitle("Two views onto the same directory model")
>
>
> app = QtGui.QApplication(sys.argv)
> t = ZeTest()
> t.show()
> app.exec_()
--
Mark Summerfield, Qtrac Ltd., www.qtrac.eu
More information about the PyQt
mailing list