[Qt-interest] How to make a table with widget entries?
K. Frank
kfrank29.c at gmail.com
Sat Mar 6 19:32:15 CET 2010
Hello All -
Bertwim's post had the key to my question:
QTableWidget::setCellWidget()
> ...
> On Thu, Mar 4, 2010 at 5:29 PM, B.W.H. van Beest <bwvb at xs4all.nl> wrote:
>> Hi,
>>
>> I would like to display a table, with at each entry a (different)
>> QWidget.
>
> In my case I would like a specific column of the table to be a set of exclusive
> choices given by a set of radio buttons.
>
>> Indeed very much like a QTableWidget.
>
> Oh, is this functionality available in QTableWidget? I could manage with
> QTableWidget instead of QTableView. I've looked at the documentation
> for QTableWidget and QTableWidgetItem, and I don't see how to put a
> widget of my choice -- for example, "radio-button-valued" cell -- in my table.
>
Now that I look more carefully at the QTableWidget documentation, I see
the setCellWidget method. It does (almost) exactly what I want, and I've
tried it out with a QGroupBox of radio buttons, with good success.
> ...
>> However, I need to set my own (table) model, but
>> QTableWidget::setModel() is unaccessible (private).
>> ...
>> Thanks in advance.
>> Bertwim
>
> In my case I have made some progress. I am using a QItemDelegate
> (following the Spin Box Delegate Example in the qt documentation)
> to use a set of radio buttons to *edit* my item. But I would also like
> to use radio buttons to *display* the item.
> ...
As for Bertwim's original question about putting a QWidget in a QTableView
I'm still stuck with being able to edit with QItemDelegate, but not
display, etc.
(Sorry, Bertwim. Your post helped me, but I haven't been able to return the
favor.)
K. Frank
More information about the Qt-interest-old
mailing list