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. In Qtableview convet julianday to Qdate

In Qtableview convet julianday to Qdate

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 2.7k 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.
  • S Offline
    S Offline
    sharan
    wrote on last edited by
    #1

    i have table in database which stores date in julianday ,
    I use QSQLRelationaltablemodel for the tableview model
    the table view displays the data in integer format so how i can i convert integer to Qdate in the qtableview

    i can use QDate::FromJulianDay ( int jd ) but how to do it in qtableview
    please reply

    1 Reply Last reply
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on last edited by
      #2

      I am assuming something like this:

      @
      QDate asd = QDate::fromJulianDay(dateFromSqlTable);
      QString dateInStringFormat = asd.toString();

      QTableView *tbView = new QTableView();
      // add wtv data you need. here you can add the data to your QAbstractItemModel

      @

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to DevNet,

        One way to do that is to use a "delegate":http://qt-project.org/doc/qt-4.8/qstyleditemdelegate.html that simply translate your integer to a QDate and from the QDate to string.

        Hope it helps

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sharan
          wrote on last edited by
          #4

          dates are only present in single column not whole table,
          is there any way to change single column only using delegates

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Something like "this":http://qt-project.org/doc/qt-4.8/qabstractitemview.html#setItemDelegateForColumn ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sharan
              wrote on last edited by
              #6

              thanks SGaist

              1 Reply Last reply
              0
              • napajejenunedk0N Offline
                napajejenunedk0N Offline
                napajejenunedk0
                wrote on last edited by
                #7

                "This":http://qt-project.org/forums/viewthread/7428 is the solution.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  No it's not, it's an explanation on how to calculate a QDateTime from a Julian day, not how to show it as a QDateTime in a QTableView

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • napajejenunedk0N Offline
                    napajejenunedk0N Offline
                    napajejenunedk0
                    wrote on last edited by
                    #9

                    Yes, and then show it in the table view. Other way to convert it is using SQLite's strftime.

                    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