开发者

Type-aware rendering (and editing) of tabular data in pyqt4

I would like to have a very short / minimal example of how to create some tabular widget with different types of it开发者_JAVA百科em 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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜