1 Attachment(s)
How to show the drive size in QDirModel
hello everyone,
I want to show the drive size in QDirModel. I try to rewrite the "SetData" function, but the parameter "value" is a quote, I cant change its value. how can I do it ? thanks.
note:
setData: setData(const QModelIndex &index, const QVariant &value, int role)
Attachment 10750
Re: How to show the drive size in QDirModel
What do you mean by -
Quote:
but the parameter "value" is a quote
The parameter value is const in the arguments and you wont be able to change its value inside the function.
But you can always pass data to it right...
Code:
model->setData(index, var, role);
:rolleyes:
Re: How to show the drive size in QDirModel
Thanks your reply.
But have a problem, the drive size in the second column , the setData have not the parameter "column". I want to show the drive size in the second column and how can I do it. thanks.
oh, I see. I try .thanks.
Added after 1 14 minutes:
I use this:
model->setData(dirModelIndex,drivesize);
and in setData function:
QString driveName = index.data().toString();
QModelIndex child;
if (driveName.length() > 1 && driveName.at(1) == QLatin1Char(':'))
{
qDebug() << "set drive size";
child = QDirModel::index(index.row(), 1, index);
setData(child, value,role);
emit dataChanged(index, index);
return true;
}
but it not effect. how can I do it? thanks.