我有QStringList
的时间(例如:“ 18:30:18”),我想将其转换为QList<double>
,我使用这些代码和函数,但它们向我返回0;
我想加倍(18:30:18);
bool allOk1(true);
QList<double> val3;
bool ok1;
for (int x = 0; x <= timeList.count()-1 && allOk1; x++) {
val3.append(timeList.at(x).toDouble(&ok1));
allOk1 &= ok1;
}
//
QList<double> time2Double(const QStringList& timeList)
{
QList<double> gdbList; // Global list
foreach(const QString& time, timeList)
{
QList<double> dbList;
for(int i = 0; i < time.size(); i++)
{
bool isNum = false; // boolean to check whether the 'time.at(i)' is a //number
double n = time.toDouble(&isNum); // your int
std::cout<<"n:"<<n<<endl;
if(isNum)
dbList << n;
}
gdbList << dbList;
}
return gdbList;
}