View Full Version : How to show the drive size in QDirModel
kartikzheng
18th November 2014, 03:54
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)
10750
aamer4yu
18th November 2014, 06:29
What do you mean by -
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...
QVariant var = 23;
model->setData(index, var, role); :rolleyes:
kartikzheng
19th November 2014, 08:17
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.