Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Convert column (type TIME in Sqlite) to QTime
Qt 6.11 is out! See what's new in the release blog

Convert column (type TIME in Sqlite) to QTime

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    creasser
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • C Offline
        C Offline
        creasser
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          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.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • C Offline
            C Offline
            creasser
            wrote on last edited by
            #5

            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") :-/

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              [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.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • C Offline
                C Offline
                creasser
                wrote on last edited by
                #7

                ah, yeah, thanks a lot

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

                1 Reply Last reply
                0
                • raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #8

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

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved