Search code examples
pyqt4qscintilla

How to use autocomplete with method of class


I cannot found how to use autocomplete for methods/properties from class.

I'm using add() for add string, but I cannot think how it can work with classes. Any one know?

Edit 1

I'm using it for funciontion

api = Qsci.QsciAPIs(lexer)
api.add("myfunction1")
api.add("myfunction2")
api.add("myfunction3")
api.prepare()

I need to complete methods of some class, for sample

myclass1 myclass1->method1 myclass1->method2

myclass2 myclass2->method1 myclass2->method3

I want to write myclass2-> and autocomplete method1, method3


Solution

  • Presumably, the format used when adding entries programmatically is the same as the one used in API files.

    API file entries look like this:

    PyQt4.QtGui.QSizePolicy.MinimumExpanding?10
    PyQt4.QtGui.QTabWidget.addTab?4(QWidget, str) -> int
    PyQt4.QtCore.QVariant.toInt?4() -> (int, bool)
    PyQt4.phonon.Phonon.createPlayer?4(Phonon.Category, Phonon.MediaSource source=Phonon.MediaSource()) -> Phonon.MediaObject
    PyQt4.QtCore.QObject.findChildren?4(tuple, str name='') -> list-of-QObject
    

    So, the format seems to be:

    • namespaces are separated by dots
    • a namespace can be followed by ?n, where n indicates an identifier to be used when registering associated images
    • the function/method signature is a comma-separated list of types in parentheses
    • the return type is indicated by -> followed by either a type, or a comma-separated list of types in parentheses

    The last three items are probably all optional (the last two are only used for call-tips).