Now i get confused!
i change the code to:
{
if(role == Qt::TextAlignmentRole)
return Qt::AlignCenter;
if(value.isValid() && role == Qt::DisplayRole){
if(idx.column() == id)
return value.toString().prepend("#");
}
return value;
}
QVariant BillyModel::data(const QModelIndex &idx, int role) const
{
QVariant value = QSqlTableModel::data(idx, role);
if(role == Qt::TextAlignmentRole)
return Qt::AlignCenter;
if(value.isValid() && role == Qt::DisplayRole){
if(idx.column() == id)
return value.toString().prepend("#");
}
return value;
}
To copy to clipboard, switch view to plain text mode
And now works!
How data() works?, i mean is it possible to return multivalue at the time or what?
Because when soething lik ethis happen
return BillyWilly;
return BillyWilly;
To copy to clipboard, switch view to plain text mode
The function shoulda return BillyWilly and stop , in this situation data() return
first:
if(role == Qt::TextAlignmentRole)
return Qt::AlignCenter;
if(role == Qt::TextAlignmentRole)
return Qt::AlignCenter;
To copy to clipboard, switch view to plain text mode
Second:
if(idx.column() == id)
return value.toString().prepend("#");
if(idx.column() == id)
return value.toString().prepend("#");
To copy to clipboard, switch view to plain text mode
But i'm sure something like this couldn't possible, and i misunderstood how the data() works!
Bookmarks