Hi,
How can I create a Class inherits from two QObject subclasses in Qt 4.3 ?
Eg:
Please help me.
Printable View
Hi,
How can I create a Class inherits from two QObject subclasses in Qt 4.3 ?
Eg:
Please help me.
It is not possible to inherit from 2 QObject classes. Instead inherit only the first one and make your class to be a wrapper around QThread - it doesn't have that many methods anyway. Create a QThread member and expose its API through your class.
EDIT: look at this... eclipse even tells you you can't inherit from two QObject's:
Hi,
I am not very clear with your answer. Can you please give an sample code for it ?
Hi,
How can I solve this problem?
Please help me
Hi,
When I try this, at the time of running the program, Qt display an error like this
Please help me to solve this problem.Quote:
First-chance exception at 0x67015e8a (QtCored4.dll) in Test.exe: 0xC0000005: Access violation reading location 0xcdcdcdd1.
Unhandled exception at 0x67015e8a (QtCored4.dll) in Test.exe: 0xC0000005: Access violation reading location 0xcdcdcdd1.
You're dereferencing an uninitialized pointer. Do you have something like
anywhere in your code?Code:
mThread = new MyThread(this);
Hi
My code is like this
Code:
{ protected: QThread *mThread; ........ public: void start() { mThread->start(); } virtual void run(); }
and in my .cpp file the code is like this
Code:
void CTest::StartCapture (int DeviceNum ){ capture = cvCaptureFromCAM( DeviceNum ); if( !capture ) { fprintf( stderr, "ERROR: capture is NULL \n" ); getchar(); } mThread->start(); } void CWebCamViewer::run() { while( true ) { // Get one frame qApp->processEvents(); ImgFrame = cvQueryFrame( capture ); if( !ImgFrame ) { fprintf( stderr, "ERROR: frame is null...\n" ); getchar(); break; } ReturnImg = IplImageToQImage(ImgFrame); hflip = hflip.scaled(320,240, Qt::IgnoreAspectRatio, Qt::FastTransformation); } }
Please help me to solve that problum.
Could you answer my question?
Hi,
No, I didn't give a line like this
in my programCode:
mThread = new MyThread(this);
So most likely mThread is an uninitialized pointer which points to 0xcdcdcdd1. Don't you think you should have
somewhere?
Hi
When I give the command in my constructor
then Qt return an error like this
Quote:
.\Test.cpp(70) : error C2259: 'QThread' : cannot instantiate abstract class
due to following members:
'void QThread::run(void)' : is abstract
c:\qt\4.3.0\include\qtcore\qthread.h(87) : see declaration of 'QThread::run'
Ahh, indeed. QThread will be non-abstract in Qt 4.4 but until that you will have to implement QThread::run().
Hi,
In my code I had implement the run(). Please see the code , which one i previous declare.
in .h file
Code:
virtual void run();
and in .cpp file
Code:
void CTest::run() { ..... ..... }
is it correct?
A friendly advise would be to learn C++ before trying to use a comprehensive toolkit written in C++. Using Qt sure requires some knowledge of C++.
What you have shown above declares a method "virtual void run()" in a class which has QThread pointer as a member. That's not at all same than implementing QThread::run().
Notice the difference between:
and
Hi,
Its my mistake. Sorry.
I create a class like this
Code:
{ protected: virtual void run(){ while(true){ qDebug()<<"Run"; } } };
and in .h file
and give the command in my constructor like this
but the error is like this
Code:
.\Test.cpp(70) : error C2259: 'QThread' : cannot instantiate abstract class due to following members: 'void QThread::run(void)' : is abstract c:\qt\4.3.0\include\qtcore\qthread.h(87) : see declaration of 'QThread::run'
Please help me
QThread is abstract. You must instantiate your QThread subclass:
Code:
mThread = new MyThread(this);
Hi,
Ohhhh, It's my mistake. Sorry.
Thankyou for your help