Results 1 to 2 of 2

Thread: Using QVector properly. Error compilation.

  1. #1
    Join Date
    Mar 2015
    Posts
    105
    Thanks
    50

    Default Using QVector properly. Error compilation.

    Good evening!

    What is wrong with the code bellow? "Number" is a class which has an constructor Number(int i, int j).
    Qt Code:
    1. QList< QVector< Number > > Lottery::patternList(QList< QVector< Number > > pl, int array[], int size)
    2. {
    3. QVector<Number> first;
    4.  
    5. if( pl.size( ) )
    6. {
    7. //Not implemented.
    8. }
    9. else
    10. {
    11. for(int i = 0; i < size; i++)
    12. if(array[i] != 0)
    13. first.push_back( Number((i + 2), array[i]) );
    14.  
    15. pl.push_back( first );
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    Error message:
    C:\Qt\5.4\mingw491_32\include\QtCore\qvector.h:281 : error: no matching function for call to 'Number::Number()'
    new (from++) T();
    ^
    Thanks!

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Using QVector properly. Error compilation.

    Hi, types stored in Qt containers must be assignable types. They must provide a default contructor, a copy constructor, and an assignment operator.

Similar Threads

  1. QVector push_back error
    By Eleasar in forum Newbie
    Replies: 5
    Last Post: 17th April 2014, 08:39
  2. [SOLVED]Weird compile error QObject, QVector
    By Alir3z4 in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2012, 16:07
  3. 0xc0000005 error when using qVector
    By przemo in forum Newbie
    Replies: 5
    Last Post: 9th December 2010, 14:02
  4. Replies: 1
    Last Post: 25th October 2008, 19:18

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.