Results 1 to 3 of 3

Thread: error: C2664: 'QAbstractItemView::setModel' : cannot convert parameter 1

  1. #1
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default error: C2664: 'QAbstractItemView::setModel' : cannot convert parameter 1

    For:

    Qt Code:
    1. QStandardItemModel model(4, 4);
    2. for (int row = 0; row < 4; ++row) {
    3. for (int column = 0; column < 4; ++column) {
    4. QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
    5. model.setItem(row, column, item);
    6. }
    7. }
    8. ui->listView->setModel(model);
    To copy to clipboard, switch view to plain text mode 

    I get:

    Qt Code:
    1. E:\Projects\loca\loca\loca.cpp:31: error: C2664: 'QAbstractItemView::setModel' : cannot convert parameter 1 from 'QStandardItemModel' to 'QAbstractItemModel *'
    2. No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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: error: C2664: 'QAbstractItemView::setModel' : cannot convert parameter 1

    You are passing an object instead of a pointer to setModel().
    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.


  3. #3
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: error: C2664: 'QAbstractItemView::setModel' : cannot convert parameter 1

    Indeed I am...

Similar Threads

  1. Replies: 3
    Last Post: 16th December 2012, 11:59
  2. How to convert this java parameter
    By razumi in forum Qt Programming
    Replies: 2
    Last Post: 15th July 2009, 05:55
  3. Is an error in doc whith QTableWidget::setModel?
    By mikolaj in forum Qt Programming
    Replies: 11
    Last Post: 8th January 2009, 20:31
  4. Replies: 8
    Last Post: 16th July 2008, 14:05
  5. cannot convert parameter 2 from 'char [80]' to 'LPWSTR'
    By sabeesh in forum Qt Programming
    Replies: 5
    Last Post: 4th December 2007, 14:21

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.