[Qt-interest] QTable model with designer GUI

emmanuel_mayssat at lynceantech.com emmanuel_mayssat at lynceantech.com
Tue Sep 14 19:40:58 CEST 2010


To answer my own problem, it turns out in designer, you have 2 ways to create tables.
You have the ITEM-WIDGETS and MODEL-BASED WIDGETS.
That is 
QTableWidget()
and
QTableView()

The method setModel is a private method of QTableWidget, 
but a public method of QTableView!!!

So if you create a QTableWidget and try to setModel, you get the error below.

Basically you need to use the correct designer widget to solve the problem.
In my case a QtableView()

--
Emmanuel




On 19:15 Mon 13 Sep     , emmanuel_mayssat at lynceantech.com wrote:
> 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
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

-- 
Emmanuel



More information about the Qt-interest-old mailing list