如何将QStringList时间转换为QList <double>?

时间:2018-07-17 20:12:21

标签: qt qstring qlist

我有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;
    }

0 个答案:

没有答案