[Qt-interest] Show a different widget in a QTableWiget cell accordin to the data
Stephen Kelly
steveire at gmail.com
Thu Jul 15 23:56:15 CEST 2010
lameire alexis wrote:
> Hi,
>
> I currently develop a school planning generator with Qt but i have a
> problem when using a QTableWidget class to show datas.
> I bult my own SQL model using Qt: this model is based on the
> AbstractSqlTable interface and each implementation of it can send datas
> to the view.
> This interface and all implementations are able to return datas as
> QVariant type.
>
> I'd rather not use the model/view Qt pattern because it doesn't respect
> the MVC pattern for my source code.
> I wrote a class which inherits from QTableWidget but i can't show on the
> cell different widgets according to the QVariant type. I would like have
> this comportement :
>
> * if data is a QString, I need to use the Qt default editor
> * else if data is a bool, I only need a QChekBox
> * else if data is a customised enum, I need to use a class of my own
> inherited from QSpinbox.
You can write a custom QItemEditorFactory.
http://doc.trolltech.com/latest/qitemeditorfactory.html
>
> For more details here are the files concerned by the problem:
>
>
http://code.google.com/p/qplanning/source/browse/trunk/src/AbstractSqlTable.cpp
>
http://code.google.com/p/qplanning/source/browse/trunk/src/AbstractSqlTable.h
> here is the SqlTableModel
>
>
http://code.google.com/p/qplanning/source/browse/trunk/src/AsyncTableWidget.cpp
>
http://code.google.com/p/qplanning/source/browse/trunk/src/AsyncTableWidget.h
> here is the inherited class
More information about the Qt-interest-old
mailing list