用于QComboBox的setPlaceholderText

用于QComboBox的setPlaceholderText

本文介绍了用于QComboBox的setPlaceholderText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在没有子类的情况下,我可以在QComboBox文本中显示未进行选择的地方吗,例如QLineEdit中的setPlaceholderText吗?

Without subclassing can I have in QComboBox text that will be shown where no selection was made, something like setPlaceholderText in QLineEdit?

推荐答案

QComboBox没有占位符文本选项,但是您可以通过两种方式实现:

QComboBox does not have a placeholder text option but you can achieve this in two ways:

  1. 添加一个带有占位符文本的项目作为组合框并处理项目选择以解决额外的问题项目.
  2. 使用 myCombo-> lineEdit()-> setPlaceholderText("Some text"); 仅在您的组合框可编辑的情况下有效.
  1. Add an item with your placeholder text as the first item in thecombobox and handle the item selection to account for the extraitem.
  2. Use myCombo->lineEdit()->setPlaceholderText("Some text"); But thiswill only work if your combobox is editable.

这篇关于用于QComboBox的setPlaceholderText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 13:12