Results 1 to 3 of 3

Thread: Using QSqlQuery

  1. #1
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4

    Default Using QSqlQuery

    hi, here are some questions about using QSqlQuery to retrieve data.

    1. This guide says that Postgre's BIGINT is mapped to qint64, so how is it possible to get a qint64 value from QSqlQuery? All data from QSqlQuety object is passed through QVariant object, which can not be constructed from qint64 and does not have toQint64() function!

    2. If I know the type of fields in my database table, is there a way to retrieve the data without using abstraction of QVariant ( I guess it makes things slower )?

  2. #2
    Join Date
    Oct 2010
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using QSqlQuery

    Hi,

    According to this page http://doc.qt.nokia.com/4.7/qtglobal...qint64-typedef
    qint64 is equivalent to long long int, which is also qlonglong, so you can build a QVariant with a qlonglong, and use either toLongLong(bool) or value<qlonglong>() on QVariant.
    For the 2nd part of your question, sorry, no idea.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Using QSqlQuery

    Quote Originally Posted by darkman_dev View Post
    2. If I know the type of fields in my database table, is there a way to retrieve the data without using abstraction of QVariant ( I guess it makes things slower )?
    Not with Qt AFAICT. You can of course use the native Postgres libraries but then you lose the Qt niceties.

Similar Threads

  1. QSqlQuery
    By yasher in forum Qt Programming
    Replies: 2
    Last Post: 23rd July 2010, 14:25
  2. QSqlQuery in PyQt4
    By wirasto in forum Newbie
    Replies: 5
    Last Post: 11th January 2010, 08:25
  3. QSqlquery
    By codeman in forum Qt Programming
    Replies: 10
    Last Post: 4th June 2009, 12:57
  4. what is going on a QSqlQuery?
    By mismael85 in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2008, 13:35
  5. QSqlQuery problem
    By MarkoSan in forum Qt Programming
    Replies: 11
    Last Post: 18th December 2007, 13:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.