[Qt-interest] Show a different widget in a QTableWiget cell accordin to the data

lameire alexis alexisis-pristontale at hotmail.com
Thu Jul 15 15:37:06 CEST 2010


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.

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