Reputation: 77
QStandardItemModel::QStandardItemModel(QObject * parent = 0)
Constructs a new item model with the given parent.
I thought models can share multiple views then why we are passing a widget to QStandardItemModel Constructor?
Upvotes: 0
Views: 227
Reputation: 21258
Actually QObject
is not a widget, so that model is not dependent on any GUI component. The QObject
argument passed to constructor because QStandardItemModel
is a QObject itself and it follows Qt's standard parent-child relationship in QObjects hierarchy. If you want your model instance get deleted when its parent object destroyed, pass its pointer to the model's constructor.
Upvotes: 1