PDA

View Full Version : QVector



sabeesh
17th September 2007, 14:19
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......

marcel
17th September 2007, 14:56
You need a default constructor for CVideoDeviceInput.

Regards

jpn
17th September 2007, 15:37
/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*>.