[PyKDE] tableview and model

Olivier Fournier o.fournier at perigord.com
Fri Feb 24 15:48:54 GMT 2006


Hello,

I don't understand why this code is correct :

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'ftable.ui'
#
# Created: Fri Feb 24 16:38:19 2006
#      by: PyQt4 UI code generator vsnapshot-20060221
#
# WARNING! All changes made in this file will be lost!

import sys
from PyQt4 import QtCore, QtGui

class Ui_FTable(object):
    def setupUi(self, FTable):
        FTable.setObjectName("FTable")
        
FTable.resize(QtCore.QSize(QtCore.QRect(0,0,400,300).size()).expandedTo(FTable.minimumSizeHint()))
       
        self.gridlayout = QtGui.QGridLayout(FTable)
        self.gridlayout.setMargin(9)
        self.gridlayout.setSpacing(6)
        self.gridlayout.setObjectName("gridlayout")
       
        self.TVTable = QtGui.QTableView(FTable)
        self.TVTable.setObjectName("TVTable")
        self.gridlayout.addWidget(self.TVTable,0,0,1,1)
       
        self.retranslateUi(FTable)
        QtCore.QMetaObject.connectSlotsByName(FTable)
   
    def tr(self, string):
        return QtGui.QApplication.translate("FTable", string, None, 
QtGui.QApplication.UnicodeUTF8)
   
    def retranslateUi(self, FTable):
        FTable.setWindowTitle(self.tr("Form"))

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    FTable = QtGui.QWidget()
    ui = Ui_FTable()
    ui.setupUi(FTable)
    ############################
    model = QtGui.QStandardItemModel(3,3)
    ui.TVTable.setModel(model)
    ############################
    FTable.show()
    sys.exit(app.exec_())


and why this code is incorrect: ( Exit with Signal 11 )

# -*- coding: utf-8 -*-

import sys
from PyQt4 import QtGui, QtCore
from ftable import Ui_FTable

class FTable(Ui_FTable):
    def __init__(self, Fenetre):
        self.setupUi(Fenetre)
       
        model = QtGui.QStandardItemModel(3,3)
        self.TVTable.setModel(model)


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    Client = QtGui.QWidget()
    ui = FTable(Fenetre=Client)
    Client.show()
    sys.exit(app.exec_())

I use Python2.4 and the last sip and pyqt snapshot ( 20060221)

I'll be happy you can help me!

Best Regards

Olivier Fournier




More information about the PyQt mailing list