Re: QTableView Model Help
Hi,
you can use index.row() and index.column().
If you want to return "default" values you return
Code:
return QSqlQueryModel(or the base class of your model
)::data(index, role
)
Re: QTableView Model Help
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:
Code:
{
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
};
Problem is data is never called :(
Re: QTableView Model Help
Quote:
Originally Posted by
tntcoda
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?
Problem is data is never called :(
Hello, you could try to add the data by using the setData() method of your model (you would have to reimplement it). It that method, you then emit the dataChanged() signal to update your view.
Arghargh