I have the following model & model data classes defined -
//custommodel.h
{
Q_OBJECT
public:
custommodel
( QObject *parent
= 0 );
~custommodel();
QVariant headerData
( int section, Qt
::Orientation orientation,
int role
= Qt
::DisplayRole ) const;
void addDeviceInfo( devicedata* aDeviceInfo );
void removeDeviceInfo( devicedata* aDeviceInfo );
void addDeviceInfoList( QList<devicedata*>& aInfoList );
void PrintDeviceNames();
private:
Q_DISABLE_COPY(custommodel)
QList<devicedata*> mNamesList;
};
class custommodel : public QAbstractListModel
{
Q_OBJECT
public:
custommodel( QObject *parent = 0 );
~custommodel();
QVariant data (const QModelIndex &index, int role) const;
int rowCount (const QModelIndex &parent=QModelIndex()) const;
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
bool insertRows ( int row, int count, const QModelIndex & parent = QModelIndex() );
bool removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() );
void addDeviceInfo( devicedata* aDeviceInfo );
void removeDeviceInfo( devicedata* aDeviceInfo );
void addDeviceInfoList( QList<devicedata*>& aInfoList );
void PrintDeviceNames();
private:
Q_DISABLE_COPY(custommodel)
QList<devicedata*> mNamesList;
};
To copy to clipboard, switch view to plain text mode
//model data class -
{
Q_OBJECT
public:
devicedata();
//copy ctor
devicedata( const devicedata& other );
~devicedata();
void setPhotoName
( QString aName
);
private:
};
Q_DECLARE_METATYPE( devicedata )
class devicedata: public QObject
{
Q_OBJECT
public:
devicedata();
devicedata( QString aName );
//copy ctor
devicedata( const devicedata& other );
~devicedata();
QString getPhotoName() const;
void setPhotoName( QString aName );
private:
QString mPhotoName;
};
Q_DECLARE_METATYPE( devicedata )
To copy to clipboard, switch view to plain text mode
For every instance of devicedata added to model, I need to have a custom widget having an image & some text below it. Should
devicedata
devicedata
To copy to clipboard, switch view to plain text mode
be of type QWidget ? Or should I have another class just for the ui functionality? Should the delegate use this widget class to draw ?
Bookmarks