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. Return of the Database
Forum Updated to NodeBB v4.3 + New Features

Return of the Database

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 1.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.
  • B Offline
    B Offline
    beowulf
    wrote on last edited by
    #1

    What is the data format that the database returns to Qt?

    For example, I ran a SELECT query in the database, it returns in what format?

    You can send this return (format) per socket?

    Example, if return an object, that object can send per socket for a client application (socket)?

    -- 0x00

    1 Reply Last reply
    0
    • C Offline
      C Offline
      costab
      wrote on last edited by
      #2

      You need to read the documentation for the qtsql module:
      http://qt-project.org/doc/qt-4.8/qtsql.html

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

        [quote author="l3e0wulf" date="1352375282"]What is the data format that the database returns to Qt?

        For example, I ran a SELECT query in the database, it returns in what format?[/quote]

        AFAIK, QVariant.This is what I use after I query from an SQL Database to retrieve the data - "QSqlQuery::value":http://qt-project.org/doc/qt-4.8/qsqlquery.html#value

        [quote author="l3e0wulf" date="1352375282"]You can send this return (format) per socket?

        Example, if return an object, that object can send per socket for a client application (socket)?[/quote]

        Sorry, I can't understand these questions. Can you make it clearer? Provide examples if possible. Thanks

        Please visit my open-source projects at https://github.com/Code-ReaQtor.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          QSQlQuery returns the QVariant as wrote Code ReaQtor. Maybe you can write your own Class which stores data from table and make it serializable. For example:
          @class TableData
          {
          QString TableName;
          QStringList ColumnNames;
          QList< QList<QVariant> > TableContent;
          }
          QDataStream &operator <<(QDataStream &out,const TableData &);
          QDataStream &operator >>(QDataStream &in, TableData &);
          @

          in ***.cpp file
          @
          QDataStream &operator <<(QDataStream &out,const TableData &tb_data)
          {
          out << tb_data.TableName << tb_data.ColumnNames << tb_data.TableContent;
          return out;
          }
          QDataStream &operator >>(QDataStream &in, TableData &tb_data)
          {
          tb_data = TableData();
          in >> tb_data.TableName >> tb_data.ColumnNames>> tb_data.TableContent;
          return in;
          }
          @

          You can serialize table in QByteArray (up to 2Gb) then transfer via Sockets.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            beowulf
            wrote on last edited by
            #5

            Thank you.
            I'll be trying soon reply to you what happened.

            -- 0x00

            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