[QSQLite] select returns all values as QString



  • I put some decimal values in a table and when I do my SELECT query value method return me a QVariant containing only string event for DECIMAL types.

    Here are my queries for creation, insertion and select :

    query.exec("create table Weight "
    "(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "
    "date DATE, "
    "morning DECIMAL, "
    "noon DECIMAL, "
    "evening DECIMAL, "
    "comment TEXT, "
    "recordDate DATETIME DEFAULT CURRENT_TIMESTAMP)");

    query.exec(QString("INSERT INTO Weight (date, morning, noon, evening, comment) VALUES ('%1', %2, %3, %4, '%5')") .arg(date).arg(morning).arg(noon).arg(evening).arg(comments[i]));

    query.exec(QString("SELECT date, morning, noon, evening, comment FROM Weight"));

    Is there a way to get my values in the corresponding types of table columns?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.