Answer the question
In order to leave comments, you need to log in
Why not call a constructor with a derived class as an argument?
Hello
I'm extending the QItemSelectionModel class. Here are its constructors:
explicit QItemSelectionModel(QAbstractItemModel *model = nullptr);
explicit QItemSelectionModel(QAbstractItemModel *model, QObject *parent);
SimpleItemSelectionModel::SimpleItemSelectionModel(QObject *parent) : QItemSelectionModel (parent)
Answer the question
In order to leave comments, you need to log in
The person left the answer, but for some reason deleted
The problem was in explicit. The compiler doesn't care if I pass the base class object
SimpleItemSelectionModel::SimpleItemSelectionModel(QObject *parent) : QItemSelectionModel (dynamic_cast<QAbstractItemModel*>(parent))
When is it possible to operate with pointers to base classes while operating on objects of derivatives?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question