Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, December 2007
combobox in tableWidget


Message 1 in thread

Hi,
how would be the easiest way to do this?
I have a tableWidget with a fixed number of rows and columns.
Each item in the table shall be either a checkbox or a comboBox.

I read something that talks about subclassing QTableWidgetItem. 
How do I do this?

Eckhard 

--
 [ signature omitted ] 

Message 2 in thread

Hi,

On Fri, December 21, 2007 10:14, Eckhard Jokisch wrote:
> how would be the easiest way to do this? I have a tableWidget with a fixed
> number of rows and columns. Each item in the table shall be either a
> checkbox or a comboBox.
>
> I read something that talks about subclassing QTableWidgetItem.
> How do I do this?
For Qt 4, you should first read about the model / view concept and create
item-delegates for this purpose:

http://doc.trolltech.com/4.3/qitemdelegate.html
http://doc.trolltech.com/4.3/model-view-programming.html
(can't reach doc.trolltech.com atm, btw, see also local docs)

For Qt 3, sub-classing is the way to go...

Also see the examples in the Qt source tree! I'm sure there is one for your
purpose...

Hope this helps, René
-- 
 [ signature omitted ] 

Message 3 in thread

While mvc is the best approach, the "quick and dirty" way is to use 
QTableWidget::setCellWidget, if you don't mind the cells having the 
widgets visible all the time.

HTH,
Susan Macchia

R. Reucher wrote:
> Hi,
> 
> On Fri, December 21, 2007 10:14, Eckhard Jokisch wrote:
>> how would be the easiest way to do this? I have a tableWidget with a fixed
>> number of rows and columns. Each item in the table shall be either a
>> checkbox or a comboBox.
>>
>> I read something that talks about subclassing QTableWidgetItem.
>> How do I do this?
> For Qt 4, you should first read about the model / view concept and create
> item-delegates for this purpose:
> 
> http://doc.trolltech.com/4.3/qitemdelegate.html
> http://doc.trolltech.com/4.3/model-view-programming.html
> (can't reach doc.trolltech.com atm, btw, see also local docs)
> 
> For Qt 3, sub-classing is the way to go...
> 
> Also see the examples in the Qt source tree! I'm sure there is one for your
> purpose...
> 
> Hope this helps, René

--
 [ signature omitted ] 

Message 4 in thread

Susan Macchia wrote:

> While mvc is the best approach, the "quick and dirty" way is to use
> QTableWidget::setCellWidget, if you don't mind the cells having the
> widgets visible all the time.
> 
> HTH,
> Susan Macchia
> 
Thanks, that's exactly what I was looking for.
And also thanks for the hint to mvc. But for the quick demo is is ok just to
use a dirty trick.
There shall be a proppeer implementation lateron but that shall be done by a
different person than me.

Cheers
Eckhard

--
 [ signature omitted ]