[Qt-interest] QTable model with designer GUI

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Tue Sep 14 07:12:30 CEST 2010


Hi Emmanuel, 

You cannot set a model on QTableWidget.  Try morphing the widget to its
ancestor QTableView in Qt Designer, which requires a table to be set.  

Tony.


> -----Original Message-----
> Sent: Tuesday, 14 September 2010 12:15
> 
> Hello,
> 
> I designed my GUi using QT designer.
> In it I have a table(self.conditionTable) , and a few buttons 
> (add, remove).
> I already wrote some code for the widget (i.e def 
> on_addPushButton_pressed ...)
> Question: How can I attached to the table a model?
> 
> If I do a self.conditionTable.setModel(myModel) in 
> ConditionTableWidget.__init__, I get a 
>  
>  File "conditionTableWidget.py", line 44, in <module>
>     widget=ConditionTableWidget()
>   File "conditionTableWidget.py", line 21, in __init__
>     self.tableWidget.setModel(self.tableWidgetModel)
> TypeError: QTableWidget.setModel() is a private method
> 
> where should I associate the view to the model?
> Regards,
> 
> PS: extra points for some pyQt4 code ;-)
> -- 
> Emmanuel




More information about the Qt-interest-old mailing list