Results 1 to 7 of 7

Thread: QVector of structures without default constructor

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Location
    Saint-Petersburg
    Posts
    50
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default QVector of structures without default constructor

    Hello. I have stucture without default constructor.
    Qt Code:
    1. struct LOGRECORD
    2. {/*.....................*/};
    3.  
    4. class M
    5. {
    6. QVector<LOGRECORD> log;
    7.  
    8. M();
    9. /*.....................*/
    10. };
    11.  
    12. M::M(): log(0, LOGRECORD(/*parameters*/))
    13. {}
    To copy to clipboard, switch view to plain text mode 
    But compiler had next errors:
    1>Compiling...
    1>VerticalGraphics.cpp
    1>tlv.cpp
    1>c:\qt\4.3.2\include\qtcore\../../src/corelib/tools/qvector.h(410) : error C2512: 'LOGRECORD' : no appropriate default constructor available
    1> c:\qt\4.3.2\include\qtcore\../../src/corelib/tools/qvector.h(396) : while compiling class template member function 'void QVector<T>::realloc(int,int)'
    1> with
    1> [
    1> T=LOGRECORD
    1> ]
    1> c:\qt\4.3.2\include\qtcore\../../src/corelib/tools/qvector.h(371) : while compiling class template member function 'QVector<T>::QVector(int,const T &)'
    1> with
    1> [
    1> T=LOGRECORD
    1> ]
    1> d:\projects\src\transaslogviewer\ParamDescr.h(39) : see reference to class template instantiation 'QVector<T>' being compiled
    1> with
    1> [
    1> T=LOGRECORD
    1> ]
    1>c:\qt\4.3.2\include\qtcore\../../src/corelib/tools/qvector.h(451) : error C2512: 'LOGRECORD' : no appropriate default constructor available
    1>Reader.cpp
    1>c:\qt\4.3.2\include\qtcore\../../src/corelib/tools/qvector.h(410) : error C2512: 'LOGRECORD' : no appropriate default constructor available
    1> c:\qt\4.3.2\include\qtcore\../../src/corelib/tools/qvector.h(396) : while compiling class template member function 'void QVector<T>::realloc(int,int)'
    1> with
    1> [
    1> T=LOGRECORD
    1> ]
    1> c:\qt\4.3.2\include\qtcore\../../src/corelib/tools/qvector.h(371) : while compiling class template member function 'QVector<T>::QVector(int,const T &)'
    1> with
    1> [
    1> T=LOGRECORD
    1> ]
    1> d:\projects\src\transaslogviewer\ParamDescr.h(39) : see reference to class template instantiation 'QVector<T>' being compiled
    1> with
    1> [
    1> T=LOGRECORD
    1> ]
    1>c:\qt\4.3.2\include\qtcore\../../src/corelib/tools/qvector.h(451) : error C2512: 'LOGRECORD' : no appropriate default constructor available
    1>Generating Code...
    1>Build log was saved at "file://d:\Projects\Win32\Obj\Debug\TransasLogViewer\Build Log.htm"
    1>TLV - 4 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    What can I correct there errors?
    Last edited by AD; 8th July 2009 at 07:49.

Similar Threads

  1. default parameters in constructor class
    By mickey in forum General Programming
    Replies: 4
    Last Post: 23rd February 2008, 18:44
  2. Q3Frame : no appropraite default constructor available
    By Project25 in forum Qt Programming
    Replies: 1
    Last Post: 27th March 2007, 23:23
  3. What default constructor?
    By bitChanger in forum General Programming
    Replies: 5
    Last Post: 15th February 2006, 19:50

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
  •  
Qt is a trademark of The Qt Company.