PDA

View Full Version : QGraphicsProxywidget / delegate control focus confusion



jamierobertson
4th September 2013, 14:02
Hi,

I've got a QTreeview in a QGraphicsScene (inside a qgraphicsproxywidget), with various delegates to display various controls (checkboxes, comboboxes, spinboxes lineedits etc). After a fair amount of effort I pretty much have all the delegate controls working in a reasonable manner.

The only outstanding problem seems to be that for controls like QSpinBoxes, or QLineEdits, if I'm editing them (i.e the control is visible), and then click somewhere on the scene (outside the QGraphicsProxyWidget), then click back in the QGraphicsProxyWidget then my program crashes with an access violation (usually in QGraphicsScene::inputMethodQuery(Qt::InputMethodQu ery query), specfically in the line QVariant value = d->focusItem->inputMethodQuery(query)).

I can see that QAbstractItemView::commitData is called when the QGraphicsProxywidget loses focus in this way and model is updated correctly. I think whats happening is that the proxywidget stores the delegate control as it's focusWidget and try's to restore it when it regains focus (but by that time it's been destroyed).

I'd be happy if I could just get it to behave as if I had clicked somewhere outside the treeview on the proxywidget.

Any Ideas?

Thanks,

Jamie

jamierobertson
5th September 2013, 21:27
calling ClearFocus on the editor controls in the delegate's setModelData seems to prevent the crash.