[PyQt] treeview
lucaberto at libero.it
lucaberto at libero.it
Tue Oct 16 16:41:26 BST 2007
Hello can you explain me why if i do this :
import sys
from PyQt4 import QtCore, QtGui
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
model = QtGui.QDirModel()
tree = QtGui.QTreeView()
tree.setModel(model)
tree.setWindowTitle(tree.tr("Dir View"))
tree.resize(640, 480)
tree.show()
sys.exit(app.exec_())
All works
But if i do this:
main file:
import sys
from PyQt4 import *
from PyQt4 import QtGui
from form_rinomina_file_impl import Form
app = QtGui.QApplication(sys.argv)
form = Form()
form.show()
app.exec_()
Form implementation file :
# -*- coding: utf-8 -*-
"""
Module implementing Form.
"""
from PyQt4.QtGui import QWidget
from PyQt4.QtCore import pyqtSignature
import sys
from PyQt4 import QtCore, QtGui
from Ui_form_rinomina_file import Ui_Form
class Form(QWidget, Ui_Form):
"""
Class documentation goes here.
"""
def __init__(self, parent = None):
"""
Constructor
"""
QWidget.__init__(self, parent)
self.setupUi(self)
@pyqtSignature("")
def on_pushButton_clicked(self):
"""
Slot documentation goes here.
"""
# TODO: not implemented yet
#raise "Not implemented yet"
self.faccio_lista()
def faccio_lista(self):
modello = QtGui.QDirModel()
self.treeView.setModel(modello)
Qtdesigner compiled file
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/luca72/Desktop/Luca/progetti_eric/rinomina_file/form_rinomina_file.ui'
#
# Created: Tue Oct 16 17:08:40 2007
# by: PyQt4 UI code generator 4.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(QtCore.QSize(QtCore.QRect(0,0,659,300).size()).expandedTo(Form.minimumSizeHint()))
self.treeView = QtGui.QTreeView(Form)
self.treeView.setGeometry(QtCore.QRect(350,50,256,192))
self.treeView.setObjectName("treeView")
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(40,50,75,25))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("Form", "PushButton", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
in the treeview nothing is show
Regards
Luca
More information about the PyQt
mailing list