qcompleter

How can I customize the QCompleter popup window in PyQt?

耗尽温柔 提交于 2021-02-18 21:50:27
问题 I have a few things for a QLineEdit's QCompleter I'm interested in customizing. I want to make it behave similar to the address / search bar in Chrome. How can I limit the number of rows that are displayed? For example, even if there are 15 matches, I only want the QCompleter to show 5. How can I resize the popup window? For example, I want to make the popup window nice and snug. As per the above example, I want the popup window to resize to 5 rows exactly without any showing any ugly scroll

QCompleter for large models

ぐ巨炮叔叔 提交于 2020-01-21 15:07:38
问题 QCompleter works slightly slow on large data sets (large models): when I start to input characters in QCombobox it passes few seconds to show auto-complete popup with variants, when input 2nd char QCompleter does not react on key press for few seconds as well. Next characters works fine. Model size is about 100K records. Is it possible to improve QCompleter performance or show popup after 2nd or 3rd input symbol? Are there some good examples? 回答1: Solution appears similar to this: https:/

Pass QModelIndex instead of QString when QCompleter highlighted

只谈情不闲聊 提交于 2020-01-17 00:34:46
问题 There is a QCompleter (set to QLineEdit) populated with QStandardItemModel. That model also populates the QTableView, I need to get the QModelIndex and select it in QTableView but it fails, it passes text instead of QModelIndex: completer.highlighted.connect(print_index) passes only the first index: completer.highlighted.connect(lambda : select_index(completer.currentIndex())) def select_index(index): table_view.setCurrentIndex(index) I read docs, but cannot understand what do I do wrong.

pyqt auto completion in a table

自闭症网瘾萝莉.ら 提交于 2019-12-24 15:57:08
问题 I need auto completion in a table. So far, I could make it work that I get the same list for the entire table. However, I need a dynamic list for each cell. How can I get update the list when I move to a new position in the cell? from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * import sys class mainWindow(QMainWindow): def __init__(self, parent = None): super(mainWindow, self).__init__(parent) self.initUI() def initUI(self): self.center_window = centerWindow

How to update QCompleter's model dynamically

随声附和 提交于 2019-12-23 09:03:36
问题 I use QCompleter with QLineEdit , and I want to update QCompleter 's model dynamically. i.e. the model's contents are updated according to QLineEdit 's text. 1) mdict.h #include <QtGui/QWidget> class QLineEdit; class QCompleter; class QModelIndex; class mdict : public QWidget { Q_OBJECT public: mdict(QWidget *parent = 0); ~mdict() {} private slots: void on_textChanged(const QString &text); private: QLineEdit *mLineEdit; QCompleter *mCompleter; }; 2) mdict.cpp #include <cassert> #include

Using a QCompleter in a QTableView with Qt and Python

别等时光非礼了梦想. 提交于 2019-12-14 02:43:57
问题 I'm reading up on how to make my QAbstractTableModel editable, and it looks pretty straightforward. But how do I set up an editable cell to use a QCompleter? I take it somehow I have to tell the QTableView to use a QLineEdit widget? How can I do this? edit: hmm, I guess it has something with QTableView.setItemDelegateForColumn() but I don't know anything about delegates or how to use them. edit: I tried RobbieE's solution, got something that sort of works but it gets the geometry of the popup

looking for example for QCompleter with segmented completion / tree models

依然范特西╮ 提交于 2019-12-12 20:19:31
问题 The PySide docs include this section on QCompleter with tree models: PySide.QtGui.QCompleter can look for completions in tree models, assuming that any item (or sub-item or sub-sub-item) can be unambiguously represented as a string by specifying the path to the item. The completion is then performed one level at a time. Let’s take the example of a user typing in a file system path. The model is a (hierarchical) PySide.QtGui.QFileSystemModel . The completion occurs for every element in the

Fail to clear QLineEdit after selecting item from QCompleter

允我心安 提交于 2019-12-12 09:13:45
问题 using PopupCompletion mode when you select an item (using arrow keys) and press return - lineEdit should become empty (i clear lineEdit when return is pressed), but lineEdit does not become empty. (If you press 'Enter' again it will empty the lineEdit). So i think pressing return does clear lineEdit, but pressing return also tells QCompleter to insert selected item into lineEdit, so it seems like nothing happens. But, if you click the item insted of selecting it with arrows - everything works

QCompleter supporting multiple items like stackoverflow tag field

不羁的心 提交于 2019-12-11 14:34:08
问题 Is there a way to make the QCompleter for pyside work more similar to how the Tag editor here on StackOverflow works? Where a user can type a word and then if there is a space it allows the autocomplete to display matching words? This post seems like it does what i want but it's in C++ How to force QCompleter to check second word in QLineEdit import os import sys import json from PySide import QtCore, QtGui class ExampleWindow(QtGui.QMainWindow): def __init__(self, parent=None): super

PyQt - Auto Completer with QLineEdit multiple times

感情迁移 提交于 2019-12-11 10:03:45
问题 I want to have the possibility to use multiple times the auto completer in my QLineEdit , I found example using QTextEdit but I can't find for QLineEdit . here is a piece of code I use (very simple one) : from PyQt5.QtGui import * from PyQt5.QtCore import * from PyQt5.QtWidgets import * import sys def main(): app = QApplication(sys.argv) edit = QLineEdit() strList = ["Germany", "Spain", "France", "Norway"] completer = QCompleter(strList,edit) edit.setCompleter(completer) edit.show() sys.exit