Rajeshwar
Rajeshwar

Reputation: 11661

Is it possible to disable an entry in QComboBox

I am currently adding items to Qcombobox as such

ui.comboBox->addItem("SomeItemA");
ui.comboBox->addItem("SomeItemB");

I wanted to know if there was a way to disable items in Qcombobox such that they are not selectable. I am using Qt5

Upvotes: 2

Views: 1715

Answers (1)

Dmitry Sazonov
Dmitry Sazonov

Reputation: 9014

Try

qobject_cast< QStandardItemModel * >( ui.comboBox->model() )->item( 0 )->setEnabled( false )

Upvotes: 5

Related Questions