Results 1 to 5 of 5

Thread: no matching function error

  1. #1
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default no matching function error

    Qt Code:
    1. int counter = 0 ;
    2. while(!n.isNull()) {
    3. QDomElement e = n.toElement();
    4. if(!e.isNull()) {
    5. if(e.tagName() != "movie"){
    6. return false;
    7. }
    8. }
    9. QDomNode c = e.firstChild();
    10. while(!c.isNull()){
    11. QDomElement k = c.toElement();
    12. tabmovies->insertRow(1);
    13. if(k.tagName() == "name"){tabmovies->setItem(counter,0,QTableWidgetItem(k.text()));}
    14. if(k.tagName() == "weburl"){ tabmovies->setItem(counter,1,QTableWidgetItem(k.text())); }
    15. if(k.tagName() == "year"){tabmovies->setItem(counter,2,QTableWidgetItem(k.text()));}
    16. if(k.tagName() == "image"){tabmovies->setItem(counter,3,QTableWidgetItem(k.text()));}
    17. if(k.tagName() == "quality"){tabmovies->setItem(counter,4,QTableWidgetItem(k.text()));}
    18. if(k.tagName() == "onhdd"){tabmovies->setItem(counter,5,QTableWidgetItem(k.text()));}
    19. if(k.tagName() == "path"){tabmovies->setItem(counter,6,QTableWidgetItem(k.text()));}
    20. c = c.nextSibling();
    21. }
    22. counter++;
    23. n = n.nextSibling();
    24. }
    25. return true;
    To copy to clipboard, switch view to plain text mode 

    I am writing a library for my movies collection which reads in xml data and stores into a tablewidget for gui/cmdline part. I have a strange error, although i specify that i want to use integer only, the compiler interprets as int& and give me error as below.


    qcldata.cpp: In member function ‘bool qcldata:rocessdata()’:
    qcldata.cpp:42: error: no matching function for call to ‘QTableWidget::setItem(int&, int, QTableWidgetItem)’
    /usr/include/QtGui/qtablewidget.h:242: note: candidates are: void QTableWidget::setItem(int, int, QTableWidgetItem*)
    qcldata.cpp:43: error: no matching function for call to ‘QTableWidget::setItem(int&, int, QTableWidgetItem)’
    /usr/include/QtGui/qtablewidget.h:242: note: candidates are: void QTableWidget::setItem(int, int, QTableWidgetItem*)
    qcldata.cpp:44: error: no matching function for call to ‘QTableWidget::setItem(int&, int, QTableWidgetItem)’
    /usr/include/QtGui/qtablewidget.h:242: note: candidates are: void QTableWidget::setItem(int, int, QTableWidgetItem*)
    qcldata.cpp:45: error: no matching function for call to ‘QTableWidget::setItem(int&, int, QTableWidgetItem)’
    /usr/include/QtGui/qtablewidget.h:242: note: candidates are: void QTableWidget::setItem(int, int, QTableWidgetItem*)
    qcldata.cpp:46: error: no matching function for call to ‘QTableWidget::setItem(int&, int, QTableWidgetItem)’
    /usr/include/QtGui/qtablewidget.h:242: note: candidates are: void QTableWidget::setItem(int, int, QTableWidgetItem*)
    qcldata.cpp:47: error: no matching function for call to ‘QTableWidget::setItem(int&, int, QTableWidgetItem)’
    /usr/include/QtGui/qtablewidget.h:242: note: candidates are: void QTableWidget::setItem(int, int, QTableWidgetItem*)
    qcldata.cpp:48: error: no matching function for call to ‘QTableWidget::setItem(int&, int, QTableWidgetItem)’
    /usr/include/QtGui/qtablewidget.h:242: note: candidates are: void QTableWidget::setItem(int, int, QTableWidgetItem*)
    make: *** [.moc_obj/qcldata.o] Error 1

    could someone please help me out with error, i think it is something simple and i am missing it..

    Thanks
    Arpit

  2. #2
    Join Date
    Oct 2009
    Posts
    8
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: no matching function error

    The 3rd parameter to QTableWidget::setItem() needs to be a pointer to a QTableWidgetItem. You need to create the QTableWidgetItem on the heap using new, instead of on the stack.

    eg:
    Qt Code:
    1. if(k.tagName() == "name"){tabmovies->setItem(counter,0,new QTableWidgetItem(k.text()));}
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to jord for this useful post:

    arpspatel (16th October 2009)

  4. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: no matching function error

    Hi,

    better use
    Qt Code:
    1. if(k.tagName() == "name"){tabmovies->setItem(counter,0,new QTableWidgetItem(k.text()));}
    2. else if(k.tagName() == "weburl"){ tabmovies->setItem(counter,1,new QTableWidgetItem(k.text())); }
    3. else if(k.tagName() == "year"){tabmovies->setItem(counter,2,new QTableWidgetItem(k.text()));}
    To copy to clipboard, switch view to plain text mode 
    it will make your application faster. Further insertRow is the "wrong" function for you because you always add a empty row at 1 but set the content for the last line. So you probably want use QTableWidget::setRowCount().

  5. The following user says thank you to Lykurg for this useful post:

    arpspatel (16th October 2009)

  6. #4
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: no matching function error

    Quote Originally Posted by jord View Post
    The 3rd parameter to QTableWidget::setItem() needs to be a pointer to a QTableWidgetItem. You need to create the QTableWidgetItem on the heap using new, instead of on the stack.

    eg:
    Qt Code:
    1. if(k.tagName() == "name"){tabmovies->setItem(counter,0,new QTableWidgetItem(k.text()));}
    To copy to clipboard, switch view to plain text mode 
    Thanks man worked instantly... i know i was missing someting simple.. thanks again.

  7. #5
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: no matching function error

    Quote Originally Posted by Lykurg View Post
    Hi,

    better use
    Qt Code:
    1. if(k.tagName() == "name"){tabmovies->setItem(counter,0,new QTableWidgetItem(k.text()));}
    2. else if(k.tagName() == "weburl"){ tabmovies->setItem(counter,1,new QTableWidgetItem(k.text())); }
    3. else if(k.tagName() == "year"){tabmovies->setItem(counter,2,new QTableWidgetItem(k.text()));}
    To copy to clipboard, switch view to plain text mode 
    it will make your application faster. Further insertRow is the "wrong" function for you because you always add a empty row at 1 but set the content for the last line. So you probably want use QTableWidget::setRowCount().
    Thanks.. i have a huge xml file, so takes abt 2 mins to read.. but this was quicker

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 15:22
  2. Regading Driver to connect Postgresql Database
    By dummystories in forum Installation and Deployment
    Replies: 38
    Last Post: 12th March 2009, 08:19
  3. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 14:43
  4. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 03:49
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 13:52

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.