For the graphical interface of the application for which I work, the user needs a combo box. When the application starts, the combo box displays a hint text, for example, "Please select", and does not show the first element of the combo box. I can not find any method for setting tooltip text in http://doc.qt.io/qt-5/qcombobox.html#currentText-prop .
Thanks in advance!
There is an elegant solution if QComboBoxthere is editable:
QComboBox
editable
myQComboBox->lineEdit()->setPlaceHolderText("Please select");
QComboBoxes that are not are editablenot in them QLineEdit, so this will not work for them.
QLineEdit
QComboBox. . setEditText( const QString& ) . comboBox, . , ( ), . , QComboBox focusOutEvent(...), : if ( currentIndex() == -1 ) setEditText( tr( "Please select" ) );. QComboBox::focusOutEvent(...).
setEditText( const QString& )
focusOutEvent(...)
if ( currentIndex() == -1 ) setEditText( tr( "Please select" ) );
QComboBox::focusOutEvent(...)