Hello,

Following Qt model-view pattern, I created a "MyModel" class.

The library I'm working with retrieves data from a store and gives me a list of XImageObjectPtr, these are shared pointers (typedef... QSharedPointer).
The underlying object has some string or binary properties.

Can I use them as is to populate my QListView ? I tried, but get exception when I start my app... However I'm unable to find out the relevant information in crash log.

So my question is about direct use of QSharedPointer as a QListView item.

My model header:
Qt Code:
  1. class DicomImageModel : public QAbstractTableModel
  2. {
  3. Q_OBJECT
  4. public:
  5. DicomImageModel(QObject *parent = 0);
  6. int rowCount(const QModelIndex &parent = QModelIndex()) const ;
  7. int columnCount(const QModelIndex &parent = QModelIndex()) const;
  8. QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
  9.  
  10. void addImage(const XImageObjectPtr image);
  11. private:
  12. std::vector<XImageObjectPtr> m_dicomImages;
  13. };
To copy to clipboard, switch view to plain text mode 

and:

Use of this model:
Qt Code:
  1. DicomImageModel model;
  2. foreach (XObjectPtr obj, XContainer::instance()->findObjectsByClass(XObject::Image)) {
  3. XImageObjectPtr image = obj.dynamicCast<XImageObject>();
  4. xLogWarning(XLogRecord::Type_User, tr("ID: %1").arg(image->getId()));
  5. model.addImage(image);
  6. }
  7. m_listview->setModel(&model);
  8. m_mainWidget->layout()->addWidget(m_listview);
To copy to clipboard, switch view to plain text mode 

Thank you