Thanks alot, that makes sense so i can just return a QString from data() depending on the row/col which is great.
It seems though that the data() function isnt being called at all? The model has 0 rows to start with, just columns so i suppose there is no need to get any data.
However when i add data to the vector from another class, the model/view needs to update and request data, any pointers on how i can do this?
This is my model class:
{
Q_OBJECT
public:
QueueModel
(QWidget * parent, queue
*q
);
// Returns data for specified index
// For putting labels on header columns
QVariant headerData
(int section, Qt
::Orientation orientation,
int role
= Qt
::DisplayRole) const;
private:
queue *que; // rows = que->GetCount()
int colCount; // Number of columns
};
class QueueModel : public QAbstractTableModel
{
Q_OBJECT
public:
QueueModel(QWidget * parent, queue *q);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
// Returns data for specified index
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
// For putting labels on header columns
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
private:
queue *que; // rows = que->GetCount()
int colCount; // Number of columns
};
To copy to clipboard, switch view to plain text mode
Problem is data is never called
Bookmarks