PDA

View Full Version : Using QSqlQuery



darkman_dev
4th February 2011, 10:43
hi, here are some questions about using QSqlQuery to retrieve data.

1. This guide (http://doc.qt.nokia.com/latest/sql-types.html) 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 )?

mpalomas
4th February 2011, 12:55
Hi,

According to this page http://doc.qt.nokia.com/4.7/qtglobal.html#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.

ChrisW67
4th February 2011, 21:40
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.