[Qt-interest] QCompleter behaviour in table view

Chris W qtinterest at psychogeeks.com
Mon Jul 18 06:09:51 CEST 2011


Hi All,

I have a small problem with a popup completer in a QTableView that some
kind soul might have a fix/workaround for.   Source code to demo the
problem is here: http://pastebin.com/TMT1v1LU

A QLineEdit with completer in a table view only displays expected
completion behaviour under some circumstances.  If you double-click or
enter edit mode explicitly (F2 on Linux) the completer works correctly
on the cell. If you trigger edit mode by just typing with a cell
selected (QAbstractItemView::AnyKeyPressed edit trigger) the result in
the edit box is not as expected, the popup does not show, and focus is
lost from the cell under edit.   I assume the popup is grabbing focus
and taking the cell back out of edit mode.

With the example code: 
With the current cell but not in edit mode at (0,0) type 'b'
Expect a popup completer showing 'bar' and 'baz' and the cell in edit
mode containing 'b'
See 'b' in a cell that is not in edit mode, no popup.
Type 'a' into the same cell.
Expect a popup completer showing 'bar' and 'baz' (still) and the cell in
edit mode containing 'ba'
See 'a' in a cell that is not in edit mode, no popup. 

The debug indicates updates to the model when none should be expected
until the user shifts focus.

I have seen mention of using event filters to stop the focus hijack but
I haven't been able to get my head around exactly where the filter
should be placed or how best to identify the offender.

Any thoughts in Qt interest land?

Regards,
Chris



More information about the Qt-interest-old mailing list