Results 1 to 14 of 14

Thread: How to extend a QWT class in order to use it in Visual Studio 2008

  1. #1
    Join Date
    Jan 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation 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

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

  3. #3
    Join Date
    Jan 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  4. #4
    Join Date
    Jan 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default 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:

    Qt Code:
    1. #include <qwt/qwt_plot.h>
    2. #include <qwt/qwt_interval.h>
    3. #include <qwt/qwt_system_clock.h>
    4.  
    5. class QwtPlotDirectPainter;
    6.  
    7. class PlotOscilloscope : public QwtPlot
    8.  
    9. {
    10.  
    11. Q_OBJECT
    12.  
    13. public:
    14.  
    15. PlotOscilloscope(QWidget *parent = NULL);
    16. virtual ~PlotOscilloscope();
    17.  
    18. virtual void replot();
    19.  
    20. protected:
    21. virtual void showEvent(QShowEvent *);
    22. virtual void resizeEvent(QResizeEvent *);
    23. virtual void timerEvent(QTimerEvent *);
    24. }
    To copy to clipboard, switch view to plain text mode 




    Quote Originally Posted by Spitfire View Post
    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.

  5. #5
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to extend a QWT class in order to use it in Visual Studio 2008

    Quote Originally Posted by cristian.a View Post
    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.

    You haven'y shown the exact error message either.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  6. #6
    Join Date
    Jan 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  7. #7
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to extend a QWT class in order to use it in Visual Studio 2008

    1. install qwt by respecting what is written in the INSTALL file coming with qwt (qmake, nmake, nmake install)
    Yes
    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

  8. #8
    Join Date
    Jan 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default 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 View Post
    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

  9. #9
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to extend a QWT class in order to use it in Visual Studio 2008

    Quote Originally Posted by cristian.a View Post
    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

  10. #10
    Join Date
    Jan 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to extend a QWT class in order to use it in Visual Studio 2008

    Quote Originally Posted by Uwe View Post
    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
    Last edited by cristian.a; 16th January 2012 at 09:08.

  11. #11
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to extend a QWT class in order to use it in Visual Studio 2008

    Quote Originally Posted by cristian.a View Post
    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

  12. #12
    Join Date
    Jan 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to extend a QWT class in order to use it in Visual Studio 2008

    Quote Originally Posted by Uwe View Post
    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

  13. #13
    Join Date
    Jan 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to extend a QWT class in order to use it in Visual Studio 2008

    Quote Originally Posted by cristian.a View Post
    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

  14. #14
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to extend a QWT class in order to use it in Visual Studio 2008

    Quote Originally Posted by cristian.a View Post
    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

Similar Threads

  1. QT4 not working in Visual Studio 2008
    By mnemonic69 in forum Installation and Deployment
    Replies: 4
    Last Post: 27th May 2010, 05:37
  2. The How-To Guide: Qt4 with Visual Studio 2008
    By thomaspu in forum Qt Programming
    Replies: 18
    Last Post: 19th March 2010, 03:47
  3. Visual Studio 2008 and Qt
    By konx in forum Installation and Deployment
    Replies: 2
    Last Post: 22nd January 2010, 21:24
  4. How to use Qt with Visual Studio 2008?
    By N3wb in forum Installation and Deployment
    Replies: 2
    Last Post: 13th August 2009, 16:23
  5. Qt 4.3.2 + Visual studio 2008
    By moowy in forum Installation and Deployment
    Replies: 6
    Last Post: 6th December 2007, 06:41

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.