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. enum QVariant::Type is obsolete?
Qt 6.11 is out! See what's new in the release blog

enum QVariant::Type is obsolete?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.0k Views 2 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.
  • JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #1
    • I need to determine the types of the columns returned from a QSqlQuery.
    • I can access the column definitions via QSqlQuery::record()::field(int). This returns a QSqlField.
    • http://doc.qt.io/qt-5/qsqlfield.html#type gives me QVariant::Type QSqlField::type() const.
    • The return type of QVariant::Type is documented at http://doc.qt.io/qt-5/qvariant-obsolete.html#Type-enum under title "Obsolete Members for QVariant"

    If it is obsolete, how come QSqlField::type() returns it? What should I be using instead to achieve this?

    JKSHJ Taz742T 2 Replies Last reply
    0
    • JonBJ JonB
      • I need to determine the types of the columns returned from a QSqlQuery.
      • I can access the column definitions via QSqlQuery::record()::field(int). This returns a QSqlField.
      • http://doc.qt.io/qt-5/qsqlfield.html#type gives me QVariant::Type QSqlField::type() const.
      • The return type of QVariant::Type is documented at http://doc.qt.io/qt-5/qvariant-obsolete.html#Type-enum under title "Obsolete Members for QVariant"

      If it is obsolete, how come QSqlField::type() returns it? What should I be using instead to achieve this?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @JonB said in enum QVariant::Type is obsolete?:

      What should I be using instead to achieve this?

      There's some info at the documentation for QVariant::type(). QVariant::Type has been superseded by QMetaType::Type.

      The integral values of the two enums are interchangeable, so you can safely reinterpret the return value of QSqlField::type() as a QMetaType::Type. You can also pass QMetaType::Type values into QSqlField::setType().

      If it is obsolete, how come QSqlField::type() returns it?

      To maintain backwards-compatibility.

      I'd imagine that in Qt 6, all instances of QVariant::Type will be fully replaced by QMetaType::Type.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      JonBJ 1 Reply Last reply
      2
      • JonBJ JonB
        • I need to determine the types of the columns returned from a QSqlQuery.
        • I can access the column definitions via QSqlQuery::record()::field(int). This returns a QSqlField.
        • http://doc.qt.io/qt-5/qsqlfield.html#type gives me QVariant::Type QSqlField::type() const.
        • The return type of QVariant::Type is documented at http://doc.qt.io/qt-5/qvariant-obsolete.html#Type-enum under title "Obsolete Members for QVariant"

        If it is obsolete, how come QSqlField::type() returns it? What should I be using instead to achieve this?

        Taz742T Offline
        Taz742T Offline
        Taz742
        wrote on last edited by
        #3
        This post is deleted!
        JonBJ 1 Reply Last reply
        0
        • JKSHJ JKSH

          @JonB said in enum QVariant::Type is obsolete?:

          What should I be using instead to achieve this?

          There's some info at the documentation for QVariant::type(). QVariant::Type has been superseded by QMetaType::Type.

          The integral values of the two enums are interchangeable, so you can safely reinterpret the return value of QSqlField::type() as a QMetaType::Type. You can also pass QMetaType::Type values into QSqlField::setType().

          If it is obsolete, how come QSqlField::type() returns it?

          To maintain backwards-compatibility.

          I'd imagine that in Qt 6, all instances of QVariant::Type will be fully replaced by QMetaType::Type.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @JKSH
          Thanks for that. I did not come across that link, if you follow the links through the manual as I said I did you don't hit http://doc.qt.io/qt-5/qvariant.html#type. I'm good to go on that.

          Are you happy with the way I'm saying I determine the "type" for a column returned from the database? I need to know that for arbitrary formatting etc. rules, e.g. suitable column alignment in a table.

          JKSHJ 1 Reply Last reply
          0
          • Taz742T Taz742

            This post is deleted!

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5
            This post is deleted!
            1 Reply Last reply
            1
            • JonBJ JonB

              @JKSH
              Thanks for that. I did not come across that link, if you follow the links through the manual as I said I did you don't hit http://doc.qt.io/qt-5/qvariant.html#type. I'm good to go on that.

              Are you happy with the way I'm saying I determine the "type" for a column returned from the database? I need to know that for arbitrary formatting etc. rules, e.g. suitable column alignment in a table.

              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              @JonB said in enum QVariant::Type is obsolete?:

              @JKSH
              Thanks for that. I did not come across that link, if you follow the links through the manual as I said I did you don't hit http://doc.qt.io/qt-5/qvariant.html#type. I'm good to go on that.

              You're welcome :) Looks like a bug/oversight in the documentation generator: https://bugreports.qt.io/browse/QTBUG-68327

              Are you happy with the way I'm saying I determine the "type" for a column returned from the database? I need to know that for arbitrary formatting etc. rules, e.g. suitable column alignment in a table.

              Yes, I think that's exactly how the designers of QSqlField intended it to be used.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              2

              • Login

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