PDA

View Full Version : QTableWidget & cellWidget : some pointers



prashant
18th October 2009, 09:48
I am creating a QTableWidget and in each sell I am setting up a custom widget:


for row in range(4):
self.qTableWidget.setCellWidget(row, 0, QtGui.QDoubleSpinBox())


This works fine. How ever when I change the value of spinBox, none of the signals
(cell*.* or item*.*) of QTableWidget is emitting. I would prefer this technique compare of another ones.

Another way to solve this problem is to use "setItemDelegate" method and using spinBox
as a delegate. What I don't like here is that when you click in a cell, your widget
will become visible and as soon as cell lost it's focus, delegate widgets become invisible.

Is there a any way I keep the the widget visible all the time and delegate technique?

wysota
18th October 2009, 11:48
This works fine. How ever when I change the value of spinBox, none of the signals
(cell*.* or item*.*) of QTableWidget is emitting.
That's because those widgets are not related to the model in any way.


Another way to solve this problem is to use "setItemDelegate" method and using spinBox
as a delegate. What I don't like here is that when you click in a cell, your widget
will become visible and as soon as cell lost it's focus, delegate widgets become invisible.

Is there a any way I keep the the widget visible all the time and delegate technique?

You can render the looks of spinbox into the cell using QStyle API.