How to extend a QWT class in order to use it in Visual Studio 2008
Hello everybody,
I am new to QT.
I have just installed qt and qwt and finally, after some struggle (I compiled qwt with qmake,etc, as described in their installation steps) it works well.
What I need to do now is to extend some of the classes that come with qwt.
I would like for example, besides the QwPlot, to have an oscilloscope like class (like the one from the exemples comming with qwt).
I tried to make a class extension and included it by hand to the ui.h (which is generated by Qt Designer).
I realised that Qt Designer does not do a both ways synchronisation (from code to GUI too).
I guess the only way to have the extended class visible would be to have make an custom widget out of it.
Is this right?
If yes, I tried to make it, but at a certain point while compiling under Visual Studio 2008 I get this error:
>moc_PlotOscilloscope.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QwtPlot::staticMetaObject" (?staticMetaObject@QwtPlot@@2UQMetaObject@@B)
1>test_designerplugin.obj : error LNK2019: unresolved external symbol "public: __thiscall PlotOscilloscope::PlotOscilloscope(class QWidget *)" (??0PlotOscilloscope@@QAE@PAVQWidget@@@Z) referenced in function "public: virtual class QWidget * __thiscall test_designerPlugin::createWidget(class QWidget *)" (?createWidget@test_designerPlugin@@UAEPAVQWidget@ @PAV2@@Z)
Could you advice?
Also could you recommand me a book explaining the phylosophy behind QT and the workflow
one has to follow in order to have Visual Studio and QT work the best?
Thank you.
Regards,
Cristian
Re: How to extend a QWT class in order to use it in Visual Studio 2008
I'm guessing you've got Q_OBJECT makro in class that doesn't derive from QObject.
As to the book, here's nce list.
To be clear, qt has nothing to do with msvc, it's just a framework that will work with any ide you use.
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Hello Spitfire,
Thank you for the books list.
Regarding compiling, the problem was comming from the
fact that I was not using QWT_DLL in the .pro defines.
Now all compiles, but I have another problem:
when I running the compiled library the program
is just crushing.
I will search further as I guess this is due to the
way I am compiling the class.
Regarding QWT, could you advice on the way one
should develop classes that extend QWT classes in Visual Studio 2008?
At this point I am making a designer_plugin collection in which I am inserting
my class, but this makes an extra project in my solution. This way it is visble from
Designer.
Is there another easier way to do this?
Thank you.
Regards,
Cristian
Re: How to extend a QWT class in order to use it in Visual Studio 2008
@Spitfire,
Thank you for the books. I had a look into them and their great.
I have question regarding inheritance of QWT objects.
Are there some compulsury functions that need to be explicitly modified
in order to be able to run them?
The problem I have now is that when I insert my extended class,
I get a heap memory problem. By debuggin I see that the problem
might come from the replot functions.
The code is as follows:
Code:
#include <qwt/qwt_plot.h>
#include <qwt/qwt_interval.h>
#include <qwt/qwt_system_clock.h>
class QwtPlotDirectPainter;
class PlotOscilloscope
: public QwtPlot
{
Q_OBJECT
public:
PlotOscilloscope
(QWidget *parent
= NULL);
virtual ~PlotOscilloscope();
virtual void replot();
protected:
}
Quote:
Originally Posted by
Spitfire
I'm guessing you've got Q_OBJECT makro in class that doesn't derive from QObject.
As to the book,
here's nce list.
To be clear, qt has nothing to do with msvc, it's just a framework that will work with any ide you use.
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Quote:
Originally Posted by
cristian.a
The problem I have now is that when I insert my extended class,
I get a heap memory problem. By debuggin I see that the problem
might come from the replot functions.
The code is as follows:
So why did you only show the header? Nobody can guess code problem just because you give some method names. :confused:
You haven'y shown the exact error message either.
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Hello everybody,
After restarting a new project I finally realized which are the steps to follow:
1. install qwt by respecting what is written in the INSTALL file coming with qwt (qmake, nmake, nmake install)
2. copy the files from the lib, src respectivly to the QTDIR lib, src
3. start a new MS-QT project
4. extend an existing widget (check custom widget howtos from qt nokia)
5. in the preprocessor in MS insert the QWT_DLL directive.
Now you can extend classes based on the QWT library.
Thank you for the support again.
Cristian
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Quote:
1. install qwt by respecting what is written in the INSTALL file coming with qwt (qmake, nmake, nmake install)
Yes
Quote:
2. copy the files from the lib, src respectivly to the QTDIR lib, src
No - I already explained many, many times why not to do this and I'm getting really tired of it: consider, that others will read this nonsense and might follow.
Instead learn how to configure your environment to build and run your application using Qwt from, where it is installed by make install !
Uwe
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Hello Uwe,
I agree with you that copying it is a problem if you are updating QT.
On the other side, as I like having libraries together, that is how I
am using it now.
thank you for pointing out the possible problem.
Cristian
Quote:
Originally Posted by
Uwe
Yes
No - I already explained many, many times why not to do this and I'm getting really tired of it: consider, that others will read this nonsense and might follow.
Instead learn how to configure your environment to build and run your application using Qwt from, where it is installed by make install !
Uwe
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Quote:
Originally Posted by
cristian.a
On the other side, as I like having libraries together, that is how I
am using it now.
Come on - QTDIR is definitly not the place, where you have all your libraries and includes or where you put your own libraries and headers to.
Sooner or later you will start to use qmake to have the rules for moc in your build process. When using qmake you want to write "CONFIG += qwt" to get all the Qwt related definitions ( like QWT_DLL ). But the installed qwt.prf uses the paths, where you have installed Qwt - not some paths where you copied them later. Next you will come back with some sort of "it doesn't work" request.
Uwe
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Quote:
Originally Posted by
Uwe
Come on - QTDIR is definitly not the place, where you have all your libraries and includes or where you put your own libraries and headers to.
Sooner or later you will start to use qmake to have the rules for moc in your build process. When using qmake you want to write "CONFIG += qwt" to get all the Qwt related definitions ( like QWT_DLL ). But the installed qwt.prf uses the paths, where you have installed Qwt - not some paths where you copied them later. Next you will come back with some sort of "it doesn't work" request.
Uwe
True.
But for the moment I am trying to have all qt related libraries together.
In any case, thank you for your fast replies.
Cristian
Added after 24 minutes:
@ Uwe,
As I would like to use them from the Designer, I guess I still have to copy
the pluggin files to the right places.
Cristian
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Quote:
Originally Posted by
cristian.a
As I would like to use them from the Designer, I guess I still have to copy
the plugin files to the right places.
No you have to configure your designer to load the plugin from the right ( = where it has been installed ) places.
Uwe
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Quote:
Originally Posted by
Uwe
No you have to configure your designer to load the plugin from the right ( = where it has been installed ) places.
Uwe
How would you do this? Is there a configuration file?
Thank you.
Cristian
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Quote:
Originally Posted by
cristian.a
How would you do this? Is there a configuration file?
Thank you.
Cristian
I read that the qt.conf file could do this or the system variables QT_PLUGGIN..etc .
For some reason the system variables seem not to work on my system (Windows 7 Ultimate).
Regarding the qt.conf file I did not manage to find the clear format it should respect (keywords etc).
Could you advice?
Thank you.
Cristian
Re: How to extend a QWT class in order to use it in Visual Studio 2008
Quote:
Originally Posted by
cristian.a
I read that the qt.conf file could do this or the system variables QT_PLUGGIN..etc .
Should work - at least, when fixing the misspelling: it is QT_PLUGIN_PATH
Uwe