PyQt4: AttributeError: 'QLineEdit' object

2019-08-19 05:48发布

问题:

I have a QLineEdit, and I want to set a placeholder text. When I call setPlaceholderText(string) I get an AttributeError, but:

>>> from PyQt4 import QtCore
>>> QtCore.PYQT_VERSION_STR
'4.7.4'
>>> QtCore.QT_VERSION_STR
'4.7.0'

and from the QAssistant:

This property holds the line edit's placeholder text.
...
This property was introduced in Qt 4.7.

回答1:

I would guess that although the libraries are very recent, the bindings are simply not that up to date.

You might want to check out PySide - a Nokia project with (IMO) fewer license issues than PyQt.