Convert column (type TIME in Sqlite) to QTime



  • Hello,
    is possible to somehow select TIME column from sqlite to pass it to QTimeEdit?

    My current construction is pretty ugly:
    ui->start_1->setTime(QTime::fromString(query.value(0).toString(), "hh:mm"));

    it's because query.value(0) returns string type :-/

    Is there any better way?

    Thanks in advance
    C.


  • Moderators

    shouldn't it return a QVariant instead of a string?
    If i'm right, then please check the type of the QVariant.



  • yep, sry QVariant(String, "10:00") - something like that... but QTimeEdit.setTime()... can't handle that format


  • Moderators

    but if it would be of type QVariant::Time you just could call QVariant::toTime()
    But if a string is returned your way from your first post is the only correct way. The plugin doesn't seem to preserve the type through the API.



  • which plugin do you mean?

    btw, as I said, the column in sqlite is type of TIME therefore I expected the TIME type will be returned, when I call through QT something like "select myTime from myTable "

    but as you can see, result is qvariant(string, "10:00") :-/


  • Moderators

    [quote author="creasser" date="1375280082"]which plugin do you mean?
    [/quote]
    i mean the Qt sqlite database plugin.

    [quote author="creasser" date="1375280082"]
    btw, as I said, the column in sqlite is type of TIME therefore I expected the TIME type will be returned, when I call through QT something like "select myTime from myTable "

    but as you can see, result is qvariant(string, "10:00") :-/[/quote]
    i know... thats why i said it seems that the plugin doesn't support it.



  • ah, yeah, thanks a lot

    pure beginner at qt, you know... :)


  • Moderators

    no problem...everyone was at some point ;)


Log in to reply
 

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