Results 1 to 3 of 3

Thread: QVector

  1. #1
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy QVector

    Hi,
    I am using QT 4.3. I have a class like this,
    ================================================== =========
    class CVideoDeviceInput: public QObject
    {
    Q_OBJECT
    private:
    struct video_channel m_VChan;
    CVideoDeviceLinux *m_pVideo;
    QVector<CVideoDeviceTuner> m_Tuners;
    int m_CurrentTuner;
    QString m_Name;
    int m_Type;
    int m_Flags;
    private slots:
    void VideoTunerSwitched(int);
    public:
    enum {
    Unknown,
    TV,
    Camera
    } InputTypes;
    CVideoDeviceInput(CVideoDeviceLinux *video, int channel);
    int GetNumber() const;
    QString GetName() const;
    int GetType() const;
    bool HasAudio() const;
    bool Select();
    int GetNumberOfTuners() const;
    CVideoDeviceTuner *GetTuner(int number = -1) ;
    int GetCurrentTuner() const;
    signals:
    void Selected(int);
    };
    ==================================================


    After that I create a QVector like this in another class like this

    QVector<CVideoDeviceInput> m_VideoInputs;


    after that i give a command in my program like this,

    m_VideoInputs.resize(0) ;

    But when i give this command and make, then qt display some errors like this,

    ==================================================
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h: In member function ‘void QVector<T>::realloc(int, int) [with T = CVideoDeviceInput]’:
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:274: instantiated from ‘void QVector<T>::resize(int) [with T = CVideoDeviceInput]’
    linux/VideoDeviceLinux.cpp:119: instantiated from here
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:398: error: no matching function for call to ‘CVideoDeviceInput::CVideoDeviceInput()†™
    linux/VideoDeviceInput.h:42: note: candidates are: CVideoDeviceInput::CVideoDeviceInput(CVideoDeviceL inux*, int)
    linux/VideoDeviceInput.h:18: note: CVideoDeviceInput::CVideoDeviceInput(const CVideoDeviceInput&)
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:274: instantiated from ‘void QVector<T>::resize(int) [with T = CVideoDeviceInput]’
    linux/VideoDeviceLinux.cpp:119: instantiated from here
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:439: error: no matching function for call to ‘CVideoDeviceInput::CVideoDeviceInput()†™
    linux/VideoDeviceInput.h:42: note: candidates are: CVideoDeviceInput::CVideoDeviceInput(CVideoDeviceL inux*, int)
    linux/VideoDeviceInput.h:18: note: CVideoDeviceInput::CVideoDeviceInput(const CVideoDeviceInput&)
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h: In copy constructor ‘CVideoDeviceInput::CVideoDeviceInput(const CVideoDeviceInput&)’:
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qobject.h:270: error: ‘QObject::QObject(const QObject&)’ is private
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:446: error: within this context
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h: In member function ‘void QVector<T>::realloc(int, int) [with T = CVideoDeviceTuner]’:
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:268: instantiated from ‘void QVector<T>::detach_helper() [with T = CVideoDeviceTuner]’
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:75: instantiated from ‘QVector<T>::QVector(const QVector<T>&) [with T = CVideoDeviceTuner]’
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:446: instantiated from ‘void QVector<T>::realloc(int, int) [with T = CVideoDeviceInput]’
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:274: instantiated from ‘void QVector<T>::resize(int) [with T = CVideoDeviceInput]’
    linux/VideoDeviceLinux.cpp:119: instantiated from here
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:398: error: no matching function for call to ‘CVideoDeviceTuner::CVideoDeviceTuner()†™
    linux/VideoDeviceTuner.h:30: note: candidates are: CVideoDeviceTuner::CVideoDeviceTuner(CVideoDeviceL inux*, int)
    linux/VideoDeviceTuner.h:15: note: CVideoDeviceTuner::CVideoDeviceTuner(const CVideoDeviceTuner&)
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:268: instantiated from ‘void QVector<T>::detach_helper() [with T = CVideoDeviceTuner]’
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:75: instantiated from ‘QVector<T>::QVector(const QVector<T>&) [with T = CVideoDeviceTuner]’
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:446: instantiated from ‘void QVector<T>::realloc(int, int) [with T = CVideoDeviceInput]’
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:274: instantiated from ‘void QVector<T>::resize(int) [with T = CVideoDeviceInput]’
    linux/VideoDeviceLinux.cpp:119: instantiated from here
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:439: error: no matching function for call to ‘CVideoDeviceTuner::CVideoDeviceTuner()†™
    linux/VideoDeviceTuner.h:30: note: candidates are: CVideoDeviceTuner::CVideoDeviceTuner(CVideoDeviceL inux*, int)
    linux/VideoDeviceTuner.h:15: note: CVideoDeviceTuner::CVideoDeviceTuner(const CVideoDeviceTuner&)
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h: In copy constructor ‘CVideoDeviceTuner::CVideoDeviceTuner(const CVideoDeviceTuner&)’:
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qobject.h:270: error: ‘QObject::QObject(const QObject&)’ is private
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h:446: error: within this context
    make: *** [VideoDeviceLinux.o] Error 1
    ================================================== ===================

    What's the error.
    How can I resize that variable and insert value to that vector.....
    Please help me......

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QVector

    You need a default constructor for CVideoDeviceInput.

    Regards

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QVector

    Quote Originally Posted by sabeesh View Post
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qvector.h: In copy constructor ‘CVideoDeviceInput::CVideoDeviceInput(const CVideoDeviceInput&)’:
    /usr/local/Trolltech/Qt-4.3.0/include/QtCore/qobject.h:270: error: ‘QObject::QObject(const QObject&)’ is private
    You cannot copy QObjects, so make it QVector<CVideoDeviceInput*>.
    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    sabeesh (19th September 2007)

Similar Threads

  1. Sorting a QVector
    By jiveaxe in forum Qt Programming
    Replies: 21
    Last Post: 11th August 2007, 19:24
  2. dynamic matrix of QStrings
    By QiT in forum Newbie
    Replies: 19
    Last Post: 4th April 2007, 09:26
  3. QVector, containers, deep copy
    By TheKedge in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2007, 05:45
  4. QVector QVarLengthArray speed question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 22nd January 2007, 09:28
  5. QVector problem
    By kingslee in forum Qt Programming
    Replies: 5
    Last Post: 19th October 2006, 10:42

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.