Results 1 to 3 of 3

Thread: problem with rowCount method

  1. #1
    Join Date
    Dec 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default problem with rowCount method

    Hi everybody,

    I defined my own TableModel using the QAbstractTableModel class...all run perfectly just i couldn't use the rowCount method in my program :

    "no Matching function for call to TableModel::rowCount const"
    "condidates are virtual int TableModel::rowCount const"

    i'm sure that i have defined correctly the virtual method but i don't know what happened ? i have also changed the example of adresse book:
    Qt Code:
    1. QVariant TableModel::data(const QModelIndex &index, int role) const
    2. {
    3. if (!index.isValid())
    4. return QVariant();
    5.  
    6. if (index.row() >= /*listOfPairs.size()*/ rowCount() || index.row() < 0)
    7. return QVariant();
    8.  
    9. if (role == Qt::DisplayRole) {
    10. QPair<QString, QString> pair = listOfPairs.at(index.row());
    11.  
    12. if (index.column() == 0)
    13. return pair.first;
    14. else if (index.column() == 1)
    15. return pair.second;
    16. }
    17. return QVariant();
    18. }
    To copy to clipboard, switch view to plain text mode 
    same fact !!
    any idea ??

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: problem with rowCount method

    How does your method look like exactly?
    What is the return type?

    Everall

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem with rowCount method

    Make sure that the declaration of the method in your subclass allows a default argument for the parent model index.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 25th November 2010, 12:37
  2. Replies: 7
    Last Post: 4th September 2010, 06:10
  3. paintEvent method problem
    By zgulser in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2010, 13:32
  4. Replies: 7
    Last Post: 18th November 2008, 18:17
  5. rowCount and model
    By steg90 in forum Newbie
    Replies: 3
    Last Post: 11th May 2007, 10:14

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.