Results 1 to 3 of 3

Thread: [SOLVED]Weird compile error QObject, QVector

  1. #1
    Join Date
    Jun 2011
    Posts
    69
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Exclamation [SOLVED]Weird compile error QObject, QVector

    Hi
    I have a weird compile error which is related to QVector :|
    here's the error

    Qt Code:
    1. make: Entering directory `/home/alireza/dev/qt/yoDownet-build-desktop-Qt_in_PATH_Debug'
    2. g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt/mkspecs/linux-g++ -I../yoDownet -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtSql -I/usr/include -I. -I. -I../yoDownet -I. -o fileinfo.o ../yoDownet/yoUtils/fileinfo.cpp
    3. In file included from ../yoDownet/yoUtils/fileinfo.h:7:0,
    4. from ../yoDownet/yoUtils/fileinfo.cpp:1:
    5. /usr/include/QtCore/qobject.h: In copy constructor 'UriStatus::UriStatus(const UriStatus&)':
    6. ../yoDownet/yoUtils/uristatus.h:6:7: instantiated from 'void QVector<T>::realloc(int, int) [with T = UriStatus]'
    7. /usr/include/QtCore/qvector.h:337:3: instantiated from 'void QVector<T>::detach_helper() [with T = UriStatus]'
    8. /usr/include/QtCore/qvector.h:398:9: instantiated from 'QVector<T>& QVector<T>::operator=(const QVector<T>&) [with T = UriStatus]'
    9. ../yoDownet/yoUtils/fileinfo.cpp:30:13: instantiated from here
    10. /usr/include/QtCore/qobject.h:333:5: error: 'QObject::QObject(const QObject&)' is private
    11. ../yoDownet/yoUtils/uristatus.h:6:7: error: within this context
    12. In file included from /usr/include/QtCore/QVector:1:0,
    13. from ../yoDownet/yoUtils/fileinfo.h:6,
    14. from ../yoDownet/yoUtils/fileinfo.cpp:1:
    15. /usr/include/QtCore/qvector.h: In member function 'void QVector<T>::realloc(int, int) [with T = UriStatus]':
    16. /usr/include/QtCore/qvector.h:532:17: note: synthesized method 'UriStatus::UriStatus(const UriStatus&)' first required here
    17. make: Leaving directory `/home/alireza/dev/qt/yoDownet-build-desktop-Qt_in_PATH_Debug'
    18. make: *** [fileinfo.o] Error 1
    19. 18:44:36: The process "/usr/bin/make" exited with code 2.
    20. Error while building project yoDownet (target: Desktop)
    21. When executing build step 'Make'
    To copy to clipboard, switch view to plain text mode 

    class source
    Qt Code:
    1. #ifndef FILEINFO_H
    2. #define FILEINFO_H
    3.  
    4. #include <QObject>
    5. #include <QString>
    6. #include <QVector>
    7. #include "uristatus.h"
    8.  
    9. class FileInfo : public QObject
    10. {
    11. Q_OBJECT
    12. public:
    13. explicit FileInfo(QObject *parent = 0);
    14.  
    15. void setIndex(const QString &index);
    16. void setPath(const QString &path);
    17. void setLength(const QString &length);
    18. void setSelected(const QString &selected);
    19. void setUris(const QVector<UriStatus> &uris);
    20.  
    21. QString index() const;
    22. QString path() const;
    23. QString length() const;
    24. QString selected() const;
    25. QVector<UriStatus> uris() const;
    26.  
    27. private:
    28. QString _index;
    29. QString _path;
    30. QString _length;
    31. QString _selected;
    32. QVector<UriStatus> _uris;
    33. };
    34.  
    35. #endif // FILEINFO_H
    To copy to clipboard, switch view to plain text mode 

    if you want the whole source code, it's on the git repo
    http://sourceforge.net/p/yodownet/git/..../tree/
    or simply just clone it
    Qt Code:
    1. git clone git://git.code.sf.net/p/yodownet/git yodownet-git
    To copy to clipboard, switch view to plain text mode 

    i really get confused by this error and i tried alot of ways, but when i comment declaration/definition of this
    Qt Code:
    1. QVector<UriStatus> uris() const;
    To copy to clipboard, switch view to plain text mode 
    then the project will compiled successfully

    thanks
    Last edited by Alir3z4; 30th January 2012 at 16:36.
    ...یه مرد هیچوقت زمین نمیخوره

  2. #2
    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: Weird compile error QObject, QVector

    You can't use QObject in QVector. You have to use pointers:
    Qt Code:
    1. QVector<UriStatus*> uris() const;
    To copy to clipboard, switch view to plain text mode 


    ...from the documentation
    QVector's value type must be an assignable data type. This covers most data types that are commonly used, but the compiler won't let you, for example, store a QWidget as a value; instead, store a QWidget *. A few functions have additional requirements; for example, indexOf() and lastIndexOf() expect the value type to support operator==(). These requirements are documented on a per-function basis.

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

    Alir3z4 (30th January 2012)

  4. #3
    Join Date
    Jun 2011
    Posts
    69
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Weird compile error QObject, QVector

    Hmmmm,
    Thank you
    Your Quote from the qt documentation is the main point
    diff
    Solved!
    Last edited by Alir3z4; 30th January 2012 at 17:21.
    ...یه مرد هیچوقت زمین نمیخوره

Similar Threads

  1. [[SOLVED]]Can't get data from QVector
    By asieriko in forum Newbie
    Replies: 1
    Last Post: 13th December 2009, 20:55
  2. SOLVED: QVector<QWidget*> problem
    By vectori in forum Qt Programming
    Replies: 3
    Last Post: 7th July 2009, 13:20
  3. Qt 4.5.1 Compile error on Windows XP [SOLVED]
    By Teuniz in forum Installation and Deployment
    Replies: 0
    Last Post: 27th April 2009, 10:18
  4. [URGENT] Weird compile error [URGENT]
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2008, 00:54
  5. Weird compile error
    By MarkoSan in forum Qt Programming
    Replies: 6
    Last Post: 3rd December 2007, 19:50

Tags for this Thread

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.