Here is how the model for the view is defined and instantiated.

Qt Code:
  1. class CommunicationModel : public QAbstractTableModel
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. static CommunicationModel* instance(QWidget* parent = 0);
  7.  
  8. int rowCount( const QModelIndex &index) const;
  9. int columnCount( const QModelIndex &index) const;
  10.  
  11. QVariant data(const QModelIndex &index, int role) const;
  12. QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
  13. Qt::ItemFlags flags( const QModelIndex& ) const ;
  14.  
  15. bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex());
  16. bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex());
  17. bool addFrame(const Can_Frame &frame);
  18. void clear();
  19.  
  20. void sort (int column, Qt::SortOrder order = Qt::AscendingOrder );
  21.  
  22. private:
  23. CommunicationModel(QObject *parent = 0);
  24.  
  25. IdentifiersModel* id_model;
  26. QList<Can_Frame> m_communication; // Communication log
  27.  
  28. };
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. CommunicationView::CommunicationView( QWidget* parent ) :
  2. PrintableTableView(parent)
  3. {
  4. m_model = CommunicationModel::instance(this);
  5. setModel(m_model);
  6.  
  7. m_delegate = new CommunicationDelegate(this);
  8. setItemDelegate(m_delegate);
To copy to clipboard, switch view to plain text mode 

.. and how I do instantiate my view ...

Qt Code:
  1. WidgetCommunication::WidgetCommunication( QWidget* parent ) :
  2. QWidget( parent )
  3. {
  4.  
  5. // Title
  6. title = new TitleFrame(this,"Communication log",true);
  7. // Body
  8. body = CommunicationView::instance(this);
  9. // Status
  10. quickSend = new QuickSend(this);
  11.  
  12. // Layout
  13. mainLayout = new QVBoxLayout(this);
  14. mainLayout->addWidget(title);
  15. mainLayout->addWidget(body);
  16. mainLayout->addWidget(quickSend);
  17.  
  18. mainLayout->setContentsMargins (0, 0, 0, 0);
  19. setLayout(mainLayout);
  20. }
To copy to clipboard, switch view to plain text mode