Results 1 to 6 of 6

Thread: Question about method named rowCount() of QSqlTableModel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2012
    Posts
    136
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 27 Times in 24 Posts

    Default Re: Question about method named rowCount() of QSqlTableModel

    The behaviour is described in http://qt-project.org/doc/qt-4.8/qsq....html#rowCount
    To see if it supports returning the size you can use the hasFeature() function (there is a link to the function in the rowcount documentation)
    To get all rows you can do a sql select that returns all rows (SELECT * FROM tablename) you can replace * with a column name u need

    If you don't mind me asking why do you want to get a count of all rows?

  2. #2
    Join Date
    Jan 2014
    Posts
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: Question about method named rowCount() of QSqlTableModel

    Quote Originally Posted by StrikeByte View Post
    The behaviour is described in http://qt-project.org/doc/qt-4.8/qsq....html#rowCount
    To see if it supports returning the size you can use the hasFeature() function (there is a link to the function in the rowcount documentation)
    To get all rows you can do a sql select that returns all rows (SELECT * FROM tablename) you can replace * with a column name u need

    If you don't mind me asking why do you want to get a count of all rows?
    Thank you first! sorry for reply late,I just see it。
    To get all rows,I can handle every row though a loop(eg· for(int i=0;i<rowcount;i++))
    Is there any better idea to traverse a table without rowcount of qsqltablemodel?thanks!

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Question about method named rowCount() of QSqlTableModel

    You can use QSqlQuery directly.

    Cheers,
    _

Similar Threads

  1. Question about method named record() in QSqlTableModel
    By silentyears in forum Qt Programming
    Replies: 7
    Last Post: 21st January 2014, 09:52
  2. QSqlQueryModel ‘s method rowcount() return 256
    By liuqin820222 in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2013, 09:16
  3. problem with rowCount method
    By sergio486 in forum Qt Programming
    Replies: 2
    Last Post: 18th December 2010, 08:37
  4. Question on subclassing QSqlTableModel
    By Doug Broadwell in forum Qt Programming
    Replies: 4
    Last Post: 13th February 2010, 00:12
  5. QSqlTableModel and QSqlTableView question
    By waynew in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2009, 00:06

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