Results 1 to 10 of 10

Thread: Progress of SQL "select"

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Progress of SQL "select"

    Sorry, I can't understand your idea. Select() function is synchronous, it doesn't return until all data would be fetched. So where from should I call processEvents()?

    Can you give some piece of example code?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Progress of SQL "select"

    Quote Originally Posted by brokensword View Post
    Select() function is synchronous, it doesn't return until all data would be fetched.
    I see we don't understand each other. Please define "progress of select statement".

  3. #3
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Progress of SQL "select"

    I have a QSqlTableModel. I fill it with data using setFilter() or select() methods of QSqlTableModel. Both are synchronous (they don't return until all records would be fetched). Operation can take more then 5 minutes.

    Everything I need to know is just how much records were fetched so far.

    I've tried to make static QSqlTableModel object, fill it with data in separate thread and call rowsCount() (query->size()) in loop in main thread. It doesn't helps - rowsCount() (and query->size)) return 0 until model would be fully filled.

    So is there any way to get QSqlTableModel filling progress info?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Progress of SQL "select"

    Quote Originally Posted by brokensword View Post
    Everything I need to know is just how much records were fetched so far.
    I see, I thought you were using QSqlQuery.

    You might try connecting to QAbstractItemModel::rowsInserted() signal.

  5. #5
    Join Date
    Sep 2007
    Posts
    31
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Progress of SQL "select"

    Didn't work. rowsInserted() signal is emmited only once - at the end of filling process.

    Quote Originally Posted by jacek View Post
    I see, I thought you were using QSqlQuery.

    You might try connecting to QAbstractItemModel::rowsInserted() signal.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Progress of SQL "select"

    Quote Originally Posted by brokensword View Post
    Didn't work. rowsInserted() signal is emmited only once - at the end of filling process.
    Too bad. I've checked the sources and it looks like QSqlTableModel (QSqlQueryModel actually) doesn't fetch the data row-by-row, but rather retrieves particular cells as needed in data() using QSqlQuery::seek().

    Maybe you could create your own model that will load data using typical while( query.next() ) loop?

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.