qDebug()<<qry.value(0).toDouble()<<","<<qry.value(0).toFloat()<<","<<qry.value(0).toString()<<","<<qry.value(0).toReal();
QSqlQuery query; QString qText = "SELECT summav_o,state "\ "FROM ordered_cost WHERE year='2016' AND month = '10'"; query.prepare(qText); if(query.exec()){ while(query.next()){ QStringList row; row.append(query.value(0).toString()); //summav_o DOUBLE(11.2) row.append(query.value(1).toString()); //state TINYINT(3) Data.append(row); }
C++ (Qt) case FIELD_TYPE_FLOAT : case FIELD_TYPE_DOUBLE : case FIELD_TYPE_DECIMAL :#if defined(FIELD_TYPE_NEWDECIMAL) case FIELD_TYPE_NEWDECIMAL:#endif type = QVariant::Double; break;
C++ (Qt)static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags){ QVariant::Type type; switch (mysqltype) { case FIELD_TYPE_TINY : case FIELD_TYPE_SHORT : case FIELD_TYPE_LONG : case FIELD_TYPE_INT24 : type = (flags & UNSIGNED_FLAG) ? QVariant::UInt : QVariant::Int; break;
C++ (Qt)static QVariant::Type qDecodeMYSQLType(int mysqltype, uint flags){ QVariant::Type type; switch (mysqltype) { case FIELD_TYPE_TINY : type = static_cast<QVariant::Type>((flags & UNSIGNED_FLAG) ? QMetaType::UChar : QMetaType::Char); break;
C++ (Qt)case FIELD_TYPE_FLOAT : case FIELD_TYPE_DOUBLE : case FIELD_TYPE_DECIMAL :#if defined(FIELD_TYPE_NEWDECIMAL) case FIELD_TYPE_NEWDECIMAL:#endif type = QVariant::Double; break;