Important: Please read the Qt Code of Conduct -

QItemSelectionModel signal selectionChanged not called

  • Hi ,

    I have a QSqlQueryModel , I set that model to QItemSelectionModel.
    QSqlQueryModel *model;
    QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
    connect(selectionModel,SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),this,SLOT(update1(const QItemSelection &, const QItemSelection &)));

    But the selectionChanged doesnot call update1(). May i know why is it not executing?


  • Moderators

    you also have to "set the selection model to the view": The view triggers then the changes in the selection model.
    The data model doesn't do anything on the selection model.

  • Why do you create a new item selection model at all? Item selection is a concern of the view, so an item selection model belongs to the view, and the view will provide a pointer to the selection model it is using.

    Use the model as provided by the view, and you're in business.

Log in to reply