PDA

View Full Version : QTableWidget - Unselect cell onClick outside of control



Yoni
18th April 2012, 08:46
Hello,
What I want:
I'm trying to implement the following behavior while using a class which derives from QtTableWidget:
When the user clicks outside the control, no cell in the table should be selected or in focus.

Current behavior:
When the user clicks outside the control the selection square remains on the last edited cell, although it does not appear editable. If I type something in the cell does get edited though

Setting I am using:
setSelectionBehavior(QAbstractItemView::SelectItem s);
setEditTriggers(QAbstractItemView::AllEditTriggers );
setShowGrid(true);


Any Ideas on how I can achieve this?

Thanks,
Yoni

mentalmushroom
18th April 2012, 10:23
Try to subclass QTableWidget and override focusOutEvent method (it gets called when a widget looses focus). There you can try to clear selection (e.g. via clearSelection method).