Search code examples
c++qtqcombobox

What signal gets the QComboBox from view?


I have a QComboBox. And an implemented QAbstractItemView set as combo box view. What signal I need to emit from my view to make the combo know that the current item has been changed? When emitting "selectionChanged" or "currentItemChanged" the selected item does not appear on the combo and the view is still shown.

    QComboBox* c = new QComboBox();
    QAbstractItemView* v = new MyComboView();
    c->setView(v);

I will try to make the problem more clear. I have custom view on the combobox, it is shown, the mouse move, mouse over events are working correctly. But I have one real problem. It is the model item is not shown on the combo when I click on it. I have tried to emit selectionChanged and currentChanged signals, it was not helpful. Do I need to write my own slots for this signals to have it working or it should be done by QT?


Solution

  • There is no such signal. QComboBox gets the information about it's view through the event filter:

    Every time a mouse is moved over the view, the current index (of the view) is set according to the mouse cursor.

    Every time a mouse button is released, the current index of the view is set as a current index of the QComboBox and the list (view) is hidden.