views:

18

answers:

1

I would like to have a very short / minimal example of how to create some tabular widget with different types of item in it.

In the first round let's say I'd like to render [["Hello", 12, True], ["World", 13, False]] (Hello as string, 12 as number (right-align), True as a checkbox for eg.), but it would be nice to have Dates, Colors, and other type of info.

Next round: editing (integer with spinbox, maybe sometimes a combobox is handy, but that may not work out of the box).

There must be a simple solution, but I couldn't find...

+1  A: 

The examples provided with Qt are fairly complete for this sort of thing, but cover your different parts in different examples. Also, they are in C++ (although you should be able to translate the examples fairly easily).

The main example page for item views is a good start. In particular, the Dir View and Chart examples have tables (or trees) with different types of values in different columns. The Editable Tree Model example shows how to make portions of the data editable. The Spin Box Delegate example also shows how to make a custom editor widget for the data. Combine the information from those, and I think you are covered.

Caleb Huitt - cjhuitt