Disable Item in Qt Combobox

后端 未结 4 1693
孤街浪徒
孤街浪徒 2021-01-03 21:20

I can\'t find a standard way to disable an individual item in a Qt combo box. Is there a facility to do this in Qt that I am missing?

4条回答
  •  被撕碎了的回忆
    2021-01-03 21:43

    Why hack.. We know the model is a QStandardItemModel...

    model = dynamic_cast< QStandardItemModel * >( combobox->model() );
    item = model->item( row, col );
    item->setEnabled( false );
    

    Clean, elegant, and no hack...

提交回复
热议问题