Results 1 to 11 of 11

Thread: Keep data in QSqlQueryModel when server is offline

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep data in QSqlQueryModel when server is offline

    Humm, bummer. I'm using a customized QSqlQueryModel where there is no select() method. =(

    /Tottish

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep data in QSqlQueryModel when server is offline

    Quote Originally Posted by Tottish View Post
    Humm, bummer. I'm using a customized QSqlQueryModel where there is no select() method. =(
    Sorry, my answer is wrong.
    You're using QSqlQueryModel instead of QSqlTableModel.
    In this case you use QSqlQueryModel::setQuery to obtain the same result
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep data in QSqlQueryModel when server is offline

    Yeah, I know how to set the query except:
    "Note that the query must be active and must not be isForwardOnly()."
    And I suppose that is why the data can't be displayed when the db-connection goes down.
    /Tottish

  4. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep data in QSqlQueryModel when server is offline

    OK.

    With QSqlTableModel the result is the same because QSqlQueryModel::select use setQuery.
    As solution you can use a QAbstractTableModel where you store the result af the query
    A camel can go 14 days without drink,
    I can't!!!

  5. #5
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep data in QSqlQueryModel when server is offline

    Thank you for replying but I'm not sure I'm following.
    I don't think there is a method called QSqlQueryModel::select and if there is I can't find it.

    Could you try to explain in more detail how I would go about saving my query in a QAbstractTableModel?

    If anyone else have other opinions on how this should best be preformed, all input is welcome.

    Thanks!
    /Tottish

  6. #6
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep data in QSqlQueryModel when server is offline

    Quote Originally Posted by Tottish View Post
    I don't think there is a method called QSqlQueryModel::select and if there is I can't find it.
    Sorry, I means QSqlTableModel::select()

    However, when you have QSqlTableModel/QSqlQueryModel you can navigate it and add a row in your QAbstractTableModel for each record in QSqlxxModel
    A camel can go 14 days without drink,
    I can't!!!

  7. #7
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep data in QSqlQueryModel when server is offline

    Ah, I think I see now, but wouldn't such an operation be really expensive if the table has a couple of hundred rows and say 25 columns (as it is in my case)?
    How fast would the interaction be with such a table compared to creating a SQLite table and "copy" the retrived query into that?
    Anyway, I'll check it out!
    Thanks for the tip!
    /Tottish

  8. #8
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep data in QSqlQueryModel when server is offline

    Using "in memory" model (I think) is faster than using a "file-system" model (like SQLITE). You can also create an "in memory" SQLITE database.
    Depends from the "size" of the data that you retrieve
    A camel can go 14 days without drink,
    I can't!!!

  9. The following user says thank you to mcosta for this useful post:

    Tottish (28th April 2011)

  10. #9
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keep data in QSqlQueryModel when server is offline

    OK mcosta, I'll go with the in memory model then. The data shouldn't be very bulky.
    Thanks a lot!
    /Tottish

Similar Threads

  1. QSqlQueryModel data update
    By psi in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2012, 03:59
  2. Server data exchange strategy
    By thru in forum General Programming
    Replies: 3
    Last Post: 21st July 2010, 20:15
  3. a faster QSqlQueryModel::data()
    By baray98 in forum Qt Programming
    Replies: 0
    Last Post: 24th September 2009, 00:56
  4. Replies: 1
    Last Post: 19th March 2009, 09:20
  5. Different data types in a QSqlQueryModel
    By Lodas in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2008, 16:31

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.