Results 1 to 3 of 3

Thread: QSqlQuery return result

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSqlQuery return result

    QString result = query.result();
    query.result() will return a pointer on a const QSqlResult . You statement can not work.

    According to Qt doc:
    Normally, you would use QSqlQuery instead of QSqlResult, since QSqlQuery provides a generic wrapper for database-specific implementations of QSqlResult.

    If you are implementing your own SQL driver (by subclassing QSqlDriver), you will need to provide your own QSqlResult subclass that implements all the pure virtual functions and other virtual functions that you need.
    Retrieving records:
    Once an active query is positioned on a valid record, data can be retrieved using value(). All data is transferred from the SQL backend using QVariants.
    Qt Code:
    1. QSqlQuery query("SELECT * FROM country");
    2. while (query.next()) {
    3. QString country = query.value(0).toString();
    4. doSomething(country);
    5. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by toutarrive; 9th April 2010 at 08:15. Reason: updated

Similar Threads

  1. Replies: 11
    Last Post: 11th April 2014, 14:11
  2. Replies: 1
    Last Post: 17th January 2010, 07:36
  3. QColorDialog always return 0 as a result
    By NoRulez in forum Qt Programming
    Replies: 8
    Last Post: 17th October 2009, 12:06
  4. Wrong compiling result by QT!!??
    By greenoaktree in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2008, 13:36
  5. QSqlQuery always return junk value while for varchar oracle.
    By ranjit2709 in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2007, 05:19

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
  •  
Qt is a trademark of The Qt Company.