Hi all..<div>i have some doubts about something is happening in my code. here is it:</div><div><br></div><div><div> w = window()</div><div> f = QtCore.QFile(":/default.txt")</div><div> f.open(QtCore.QIODevice.ReadOnly)</div>
<div> model = TreeModel(QtCore.QString(f.readAll()))</div><div> f.close()</div><div> w.ui.lineEdit.setFocus()</div><div> w.ui.treeView.setModel(model) </div><div> w.show()</div><div><br></div><div>this works only in init code of application ex:</div>
<div><br></div><div><div>if __name__ == "__main__":</div><div> app = QtGui.QApplication(sys.argv)</div><div> w = window()</div><div> f = QtCore.QFile(":/default.txt")</div><div> f.open(QtCore.QIODevice.ReadOnly)</div>
<div> model = TreeModel(QtCore.QString(f.readAll()))</div><div> f.close()</div><div> w.ui.lineEdit.setFocus()</div><div> w.ui.treeView.setModel(model) </div><div> w.show()</div><div> sys.exit(app.exec_())</div>
<div><br></div><div>my question is.. why this not work:</div><div><br></div><div><div>class window(QtGui.QWidget,Ui_Form):</div><div> </div><div> def __init__(self,parent=None):</div><div> QtGui.QWidget.__init__(self,parent)</div>
<div> self.ui = Ui_Form()</div><div> self.ui.setupUi(self)</div><div> self.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.populaCombo)</div><div> f = QtCore.QFile(":/default.txt")</div>
<div> f.open(QtCore.QIODevice.ReadOnly)</div><div> model = TreeModel(QtCore.QString(f.readAll()))</div><div> f.close()</div><div> self.ui.lineEdit.setFocus()</div><div> self.ui.treeView.setModel(model) </div>
<div><br></div><div>when i put on __init__ of inherited class even the file is read..</div><div>thanks in advance.</div><div><br></div><div>Tobias </div><div>Belo Horizonte </div><div>Brasil</div></div></div></div>