PDA

View Full Version : QSpinBox Right-Click



mbrusati
30th January 2009, 18:13
I have a QSpinBox in the cell of a QTableWidget. When I right-click in the QSpinBox I popup a context menu associated with the table. The problem is the QSpinBox also signals editingFinished whenever it's right-clicked, even if successive right-clicks occur without leaving the spin box. Is there a way to disable this behavior such that I only see editingFinished when enter is pressed or the spin box loses focus?

ToddAtWSU
30th January 2009, 18:40
Can you override the QSpinBox's editingFinished function and just ignore the event so it will be passed up to its parent, assuming the table is the parent. You might also have to capture the keyPressEvent to see if Enter was pressed and the focusOutEvent for losing focus. Hope this helps.

wysota
30th January 2009, 18:47
editingFinished() is a signal, so there is no practical way of overriding it.

ToddAtWSU
30th January 2009, 18:49
Sorry I misread his post. He could just connect this signal to a slot and ignore it, right?

mbrusati
30th January 2009, 19:11
I am connected to editingFinished, since I want to do something when enter is pressed. In order to handle the SIGNAL as you suggest, I would need to know if it was triggered by a right-click. I considered setting a flag when the contextMenuEvent is called, but I wasn't sure the order (contextMenuEvent vs. editingFinished) could be guaranteed.