Argument issue in QCompleter

Phil Thompson phil at riverbankcomputing.com
Fri Jul 9 14:38:58 BST 2021


On 09/07/2021 07:40, Gottfried Müller wrote:
> Hello,
> 
> in the Qt documentation the parent argument is a keyword. Creating an
> instance with QCompleter(QStandardItemModel, parent=parentObj) brings 
> an
> error.
> 
> I am using Python 3.9.5 and PyQt5 5.15
> 
> 
> Here my code:
> 
> import sys
> from PyQt5.QtWidgets import QApplication, QWidget, QCompleter
> from PyQt5.QtGui import QStandardItemModel
> 
> class ApplWindow(QWidget):
> 
>     def __init__(self, parent=None):
>         super().__init__(parent)
>         QCompleter(["aaaa", "bbbb"], parent=self)
>         # the following statement has the execution error:
>         # TypeError: 'parent' is an unknown keyword argument
>         #QCompleter(QStandardItemModel(parent=self), parent=self)
>         # this statement is accepted
>         QCompleter(QStandardItemModel(parent=self), self)
> 
> def main():
>     appl = QApplication(sys.argv)
>     applWindow = ApplWindow()
>     applWindow.show()
>     return appl.exec_()
> 
> if __name__ == "__main__":
>     main()

It will be fixed in the next PyQt5 and PyQt6 snapshots.

Thanks,
Phil


More information about the PyQt mailing list