Hi,

i wonder what is a better practice of passing pointers to childwidgets (if their is anything like a common good practice ) of this two possibilities: Passing the Baseclass or MyClass?

I have a MainWindow and need to pass a pointer to subclass of QSqlTableModel to a childwidget:

mainwindow.cpp
Qt Code:
  1. MyQSqlTableModel *tm = new MyQSqlTableModel;
  2. ChildWidget *cw = new ChildWidget( this );
  3. cw->setTableModel( tm );
To copy to clipboard, switch view to plain text mode 

1. childwidget.cpp
Qt Code:
  1. void ChildWidget::setTableModel( QAbstractItemModel *model )
  2. {
  3. m_model = qobject_cast<MyQSqlTableModel *>(model);
  4. m_model->doSomething();
To copy to clipboard, switch view to plain text mode 


2. childwidget.cpp
Qt Code:
  1. void ChildWidget::setTableModel( MyQSqlTableModel *model )
  2. {
  3. m_model = model;
  4. m_model->doSomething();
To copy to clipboard, switch view to plain text mode 

I have seen both and wonder what the difference is and what the better approach might be.