简体   繁体   English

pyqt5选中item时,如何在组合框中显示item?

[英]How to display the item in the combo box when the item is selected in pyqt5?

I need to display the element in combo box's text box only when the element is selected other wise it should be blank in Pyqt5. Say I added elements like Apple, orange, grapes and mango in the pyqt5 combo box.仅当元素被选中时,我才需要在组合框的文本框中显示该元素,否则它在 Pyqt5 中应该为空白。假设我在 pyqt5 组合框中添加了苹果、橙子、葡萄和芒果等元素。 Usually the element apple appear in combo box's text box with out selection.通常元素 apple 出现在组合框的文本框中,没有选择。 But I need the element to be displayed only after i select this item or any element.但我只需要在 i select 这个项目或任何元素之后显示该元素。 Is there a way to do this?有没有办法做到这一点?

If you just want the QComboBox to be empty until an item is selected from the drop down box, you can use .setCurrentIndex(-1) .如果您只是希望 QComboBox 在从下拉框中选择一个项目之前为空,则可以使用.setCurrentIndex(-1)

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

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