Search code examples
qtqcombobox

QComboBox::setModel emits editTextChanged, how to block this?


I am setting a model to QComboBox on editTextChanged. While setting a model it again emits an editTextChanged signal on editTextChanged. I am using an SQL like query for filtering combobox items. pls help me


Solution

  • You can temporarily disable all signals emitted from QComboBox using blockSignals(ture);

    QComboBox* combo = /* ..... */
    
    combo->blockSignals(true);
    combo->setModel(newModel);
    combo->blockSignals(false);