[Qt-interest] How to make a table with widget entries?
K. Frank
kfrank29.c at gmail.com
Fri Mar 5 15:37:32 CET 2010
Hello -
I have a similar question:
(Bertwim, sorry to be asking questions, rather than answering yours...)
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.
I don't need my own model. So if QTableWidget supports putting a custom
widget in a cell, could someone please point me to some documentation
or an example that could get me started?
> 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.
I see that QItemDelegate has a paint() method, but I don't see how I
would use it (short of painting an image of the radio buttons from scratch.)
I want to be able to use a custom widget -- ideally as automatically as
possible -- for both display and editing of the data in the table.
(Note, for me this is not an urgent question. I am trying to learn and
understand qt. I would like to explore the kinds of things qt has been
designed and built to do, and learn the "best-practices," qt way of doing
things.)
Thanks for any advice and insight.
K. Frank
More information about the Qt-interest-old
mailing list