GlobalSearchWidget - Strange behavior

Hello,

I’m experiencing some unexpected behavior with the GlobalSearchWidget from tk-framework-qtwidgets. When typing the completer shows it’s popup and I can arrow through the list of entities. If I press return or I click an item in the list the QLineEdit is cleared. What I was expecting to happen is for this to commit the entities name to the QLineEdit.

The only way I can get the text to stay in the QLineEdit is if I hit tab or simply click on another widget so the completer’s popup loses focus.

Any ideas on why this widget works this way, or how I can adjust it?

2 Likes

In case anyone else runs into this, my solution was to disconnect the “clear” slot from the QCompleter’s “entity_activated” signal.

widget = search_widget.GlobalSearchWidget(...)
widget.completer().disconnect(widget.clear)

I would create an issue in the tk-framework-qtwidgets repo but it looks like issues are disabled there.

5 Likes

Thanks for closing the loop on the solve, @Dan_Bradham—we’ll relay your finding to the team. :slight_smile:

1 Like

Been a while, but this doesn’t seem to work anymore in python 3.10 (Desktop 1.9.2). I get:

search_widget = global_search_widget.GlobalSearchWidget(self)
search_widget.completer().disconnect(search_widget.clear)
TypeError: 'PySide2.QtCore.QObject.disconnect' called with wrong argument types:
  PySide2.QtCore.QObject.disconnect(method)
Supported signatures:
  PySide2.QtCore.QObject.disconnect(PySide2.QtCore.QMetaObject.Connection)
  PySide2.QtCore.QObject.disconnect(PySide2.QtCore.QObject, bytes, typing.Callable)
  PySide2.QtCore.QObject.disconnect(bytes, typing.Callable)
  PySide2.QtCore.QObject.disconnect(PySide2.QtCore.QObject, typing.Optional[bytes] = None)
  PySide2.QtCore.QObject.disconnect(bytes, PySide2.QtCore.QObject, bytes)
  PySide2.QtCore.QObject.disconnect(PySide2.QtCore.QObject, PySide2.QtCore.QMetaMethod, PySide2.QtCore.QObject, PySide2.QtCore.QMetaMethod)
  PySide2.QtCore.QObject.disconnect(PySide2.QtCore.QObject, bytes, PySide2.QtCore.QObject, bytes)

Is there another way to do this right?

Not sure it’s technically “right” but I got it working with the following:

search_widget = global_search_widget.GlobalSearchWidget(self)
QtCore.QObject.disconnect(search_widget.completer(), QtCore.SIGNAL("entity_activated(const QModelIndex&)"), search_widget.clear)