pyqt5 autocomplete QLineEdit - Google places autocomplete

前端 未结 2 809
北海茫月
北海茫月 2021-01-16 11:46

I am trying to create something like this (autocomplete places) in pyqt5 QLineEdit.

There is a class called QCompleter with which i can suggest the

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-16 12:16

    I faced the same issue, at first I tried @eyllanasec's answer. But for some reason, the performance is not so good (often stuck or hang) in the platform that I use (I was creating a plugin for Qt-based software using PyQt). It is running fine independently though, so perhaps it's specific to my platform.

    In the end, I found a Qt example project for a similar case, Google Suggest. You can find it https://doc.qt.io/qt-5/qtnetwork-googlesuggest-example.html. It creates a custom class to handle the search and the pop-up window (using QTreeWidget).

    Since the example is in Qt, I port it to PyQt with small modification https://github.com/ismailsunni/scripts/blob/master/autocomplete_from_url.py

提交回复
热议问题