Results 1 to 5 of 5

Thread: QAbstractItemView problem

  1. #1
    Join Date
    Sep 2007
    Posts
    21
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QAbstractItemView problem

    How I can property inherit that class? I done something like that:

    Qt Code:
    1. class OptionalModel : public QAbstractItemView
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. OptionalModel(QWidget *parent = 0);
    7. ~OptionalModel();
    8.  
    9. QRect visualRect(const QModelIndex &index);
    10. void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
    11. QModelIndex indexAt(const QPoint &point);
    12. QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
    13. int horizontalOffset();
    14. int verticalOffset();
    15. bool isIndexHidden(const QModelIndex &index);
    16. void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
    17. QRegion visualRegionForSelection(const QItemSelection &selection);
    18.  
    19. private slots:
    20. void selectAll();
    21. };
    To copy to clipboard, switch view to plain text mode 

    Of cource its initalised in one .cpp file but I still get this error when compiling:
    error C2259: 'OptionalModel' : cannot instantiate abstract class

    What I must do to fix that ?

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAbstractItemView problem

    You didn't reimplement all abstract methods or you didn't declare them correctly.
    For instance, indexAt should be const:
    Qt Code:
    1. QModelIndex indexAt ( const QPoint & point ) const;
    To copy to clipboard, switch view to plain text mode 

    Also, visualRect is also const.
    So take another look at the QAbstractItemView interface and define all functions properly.

    Regards

  3. #3
    Join Date
    Sep 2007
    Posts
    21
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAbstractItemView problem

    Thank you...

  4. #4
    Join Date
    Sep 2007
    Posts
    21
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAbstractItemView problem

    Ok I will ask one more question here, I now use QStandardItemModel as constructor and I found how to add items but they all seems like children, no parent... How I can create parent for some child items?

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

    Default Re: QAbstractItemView problem

    You can't add parents. If you add a child item to an item, you at the same time determine that the first item is the parent of the other. You can't have more than one parent for an item and you can't build the tree bottom-up, only top-down. I hope I understood your question

Similar Threads

  1. [QMYSQL] connection problem
    By chaos_theory in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd July 2007, 09:52
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.