学习PySide时,我正在调整文本编辑小部件(QLineEdit),并尝试使用如下代码片段中的setPlaceHolderText设置占位符文本(我从main
中调用它)。不幸的是,它没有像我预期的那样工作。代码可以运行,但文本框为空,没有显示占位符文本。我在Windows 7上,使用Python 2.7(在iPython中工作)。
class MyTextEdit(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.textEditor=QtGui.QLineEdit(self)
self.textEditor.move(50,15)
self.textEditor.setPlaceholderText("Don't mind me.")
self.setGeometry(100, 100, 200, 50)
self.show()
有人知道我做错了什么吗?我正在按照以下网站的示例操作:http://nullege.com/codes/search/PyQt4.QtGui.QLineEdit.setPlaceholderText和http://www.pythoncentral.io/pyside-pyqt-tutorial-interactive-widgets-and-layout-containers/。但我没有发现我做错了什么。请帮忙检查一下。