简体   繁体   English

QComboBox.setPlaceholderText() 不起作用

[英]QComboBox.setPlaceholderText() not working

I am currently trying to make some changes to a GUI application, which uses qtpy extensively.我目前正在尝试对广泛使用qtpy的 GUI 应用程序进行一些更改。 For a certain condition, the text for a combo box is to be set to a certain value.对于特定条件,组合框的文本将设置为特定值。

For this I used self.colormapComboBox.setPlaceholderText("RGB") , where colormapComboBox is an object of the class qtpy.QtWidgets.QComboBox .为此,我使用了self.colormapComboBox.setPlaceholderText("RGB") ,其中 colormapComboBox 是qtpy.QtWidgets.QComboBox类的对象。 Documentation referred: this文档参考: this

It results in the error:它导致错误:

AttributeError: 'QComboBox' object has no attribute 'setPlaceholderText'

What can be done to solve this?可以做些什么来解决这个问题?

First make your comboBox editable.首先使您的组合框可编辑。 Then you need to use this line of code.那么就需要用到这行代码了。 self.colormapComboBox.lineEdit().setPlaceholderText("RGB")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM