Results 1 to 12 of 12

Thread: Qwt examples

  1. #1
    Join Date
    Jun 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Qwt examples

    Hi to all! Some time ago I downloaded Qwt. All OK. Compiling OK. Installing OK.
    A troubles with using in project was resolved successfully. But I need a histogram.
    Well, there is an example present in source code. Good. Building... OK.
    Trying to start examples one by one.
    bode - segmentation fault
    cpuplot - symbol lookup error: ./cpuplot: undefined symbol: _ZNK9QwtLegend4findEPK20QwtLegendItemManager ????
    curvedemo1, curvedemo1 - segmentation fault
    data_plot - segmentation fault :-/
    dials - ok :-D
    event_filter - ok :-)
    histogram - segmentation fault :-/
    radio - ok :-D
    realtime - segmentation fault :-/
    simple - segmentation fault :-/
    sliders - ok :-D
    spectrogram - segmentation fault >:-/
    sysinfo - ok :-)

    So, it`s a pity, but I can`t see most interesting examples. Well. I`m trying to write a histogram for my project. Step by step I`m trying to understand what`s wrong with example "histogram". As I understood there are no class like QwtHistogram. So, in example I have
    Qt Code:
    1. class HistogramItem: public QwtPlotItem
    2. {
    3. public:
    4. explicit HistogramItem(const QString &title = QString::null);
    5. explicit HistogramItem(const QwtText &title);
    6. virtual ~HistogramItem();
    7.  
    8. void setData(const QwtIntervalData &data);
    9. const QwtIntervalData &data() const;
    10.  
    11. void setColor(const QColor &);
    12. QColor color() const;
    13.  
    14. virtual QwtDoubleRect boundingRect() const;
    15.  
    16. virtual int rtti() const;
    17.  
    18. virtual void draw(QPainter *, const QwtScaleMap &xMap,
    19. const QwtScaleMap &yMap, const QRect &) const;
    20.  
    21. void setBaseline(double reference);
    22. double baseline() const;
    23.  
    24. enum HistogramAttribute
    25. {
    26. Auto = 0,
    27. Xfy = 1
    28. };
    29.  
    30. void setHistogramAttribute(HistogramAttribute, bool on = true);
    31. bool testHistogramAttribute(HistogramAttribute) const;
    32.  
    33. protected:
    34. virtual void drawBar(QPainter *,
    35. Qt::Orientation o, const QRect &) const;
    36.  
    37. private:
    38. void init();
    39.  
    40. class PrivateData;
    41. PrivateData *d_data;
    42. };
    To copy to clipboard, switch view to plain text mode 

    I wrote a test as copy of example:
    Qt Code:
    1. #include <stdlib.h>
    2. #include <qapplication.h>
    3. #include <qpen.h>
    4. #include <qwt_plot.h>
    5. #include <qwt_plot_grid.h>
    6. #include <qwt_plot_marker.h>
    7. #include <qwt_interval_data.h>
    8. #include "histogram_item.h"
    9.  
    10. int main(int argc, char **argv)
    11. {
    12. QApplication a(argc, argv);
    13.  
    14. QwtPlot* plot = new QwtPlot(0);
    15. plot->setCanvasBackground(QColor(Qt::white));
    16. plot->setTitle("Histogram");
    17.  
    18. QwtPlotGrid *grid = new QwtPlotGrid;
    19. grid->enableXMin(true);
    20. grid->enableYMin(true);
    21. grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
    22. grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
    23. grid->attach(plot);
    24.  
    25. HistogramItem *histogram = new HistogramItem();
    26. histogram->setColor(Qt::darkCyan);
    27.  
    28. const int numValues = 20;
    29.  
    30. QwtArray<QwtDoubleInterval> intervals(numValues);
    31. QwtArray<double> values(numValues);
    32.  
    33. double pos = 0.0;
    34. for ( int i = 0; i < (int)intervals.size(); i++ )
    35. {
    36. const int width = 5 + rand() % 15;
    37. const int value = rand() % 100;
    38.  
    39. intervals[i] = QwtDoubleInterval(pos, pos + double(width));
    40. values[i] = value;
    41.  
    42. pos += width;
    43. }
    44.  
    45. histogram->setData(QwtIntervalData(intervals, values));
    46. histogram->attach(plot);
    47.  
    48. plot->setAxisScale(QwtPlot::yLeft, 0.0, 100.0);
    49. plot->setAxisScale(QwtPlot::xBottom, 0.0, pos);
    50. plot->replot();
    51.  
    52. #if QT_VERSION < 0x040000
    53. a.setMainWidget(&plot);
    54. #endif
    55.  
    56. plot->resize(600,400);
    57. plot->show();
    58.  
    59. return a.exec();
    60. }
    To copy to clipboard, switch view to plain text mode 
    and got segmentation fault in return a.exec();

    Can you help me? Were is problem may be? May be another way present to make histogram?
    Thanks a lot everyone!

  2. #2
    Join Date
    Jun 2008
    Posts
    7
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt examples

    I can't help with your seg faults but if you are interested in a histogram, I am using the QwtPlotHistogram which is in the SVN development trunk (5.2). I have found it quite useful.

    -Dean

  3. The following user says thank you to DKL1972 for this useful post:

    genomega (7th May 2010)

  4. #3
    Join Date
    Jun 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt examples

    Quote Originally Posted by DKL1972 View Post
    I can't help with your seg faults but if you are interested in a histogram, I am using the QwtPlotHistogram which is in the SVN development trunk (5.2). I have found it quite useful.
    -Dean
    Thanks a lot! All OK, but at
    Qt Code:
    1. QwtPlotHistogram *histogram = new QwtPlotHistogram();
    To copy to clipboard, switch view to plain text mode 
    I`ve got:
    /home/Andrei/Projects/Rados/RadosSeparatorQT/RadosSeparatorQT: symbol lookup error: /home/Andrei/Projects/Rados/RadosSeparatorQT/RadosSeparatorQT: undefined symbol: _ZN16QwtPlotHistogramC1ERK7QString
    Trying to to understand this...

  5. #4
    Join Date
    Jun 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt examples

    I is seems that I`ve got dynamically linking problem...
    my *.pro file:
    Qt Code:
    1. QWT_ROOT = qwt
    2.  
    3. include( $${QWT_ROOT}/qwtconfig.pri )
    4.  
    5. SUFFIX_STR =
    6. VVERSION = $$[QT_VERSION]
    7. isEmpty(VVERSION) {
    8.  
    9. # Qt 3
    10. debug {
    11. SUFFIX_STR = $${DEBUG_SUFFIX}
    12. }
    13. else {
    14. SUFFIX_STR = $${RELEASE_SUFFIX}
    15. }
    16. }
    17. else {
    18. CONFIG(debug, debug|release) {
    19. SUFFIX_STR = $${DEBUG_SUFFIX}
    20. }
    21. else {
    22. SUFFIX_STR = $${RELEASE_SUFFIX}
    23. }
    24. }
    25.  
    26. INCLUDEPATH += $${QWT_ROOT}/src
    27. DEPENDPATH += $${QWT_ROOT}/src
    28. QWTLIB = qwt$${SUFFIX_STR}
    29. LIBS += -L$${QWT_ROOT}/lib -l$${QWTLIB}
    30.  
    31. TEMPLATE = app
    32. TARGET = RadosSeparatorQT
    33. QT += core \
    34. gui \
    35. xml \
    36. network \
    37. thread
    38. HEADERS += header1.h \
    39. header2.h \
    40. ...
    41.  
    42. SOURCES += source1.cpp \
    43. source2.cpp \
    44. ...
    45. FORMS += Form1.ui \
    46. Form2.ui \
    47. ...
    48. RESOURCES += Resource.qrc
    To copy to clipboard, switch view to plain text mode 

    is it correct?
    Last edited by jpn; 1st July 2008 at 07:20. Reason: changed [qtclass] to [code] tags

  6. #5
    Join Date
    Jun 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt examples

    Another variant of *.pro file
    Qt Code:
    1. INCLUDEPATH += qwt/src
    2. unix:LIBS += -L/qwt/lib -llibqwt
    3. TEMPLATE = app
    4. TARGET = RadosSeparatorQT
    5. QT += core \
    6. gui \
    7. xml \
    8. network \
    9. thread
    10. HEADERS += header1.h \
    11. header2.h \
    12. ...
    13. SOURCES += source1.cpp \
    14. source2.cpp \
    15. ...
    16. FORMS += Form1.ui \
    17. Form2.ui \
    18. ...
    19. RESOURCES += Resource.qrc
    To copy to clipboard, switch view to plain text mode 

    So. I`ve got from from SVN development trunk version 5.2. Before compile and install I changed in qwt.pri CONFIG += QwtDll to CONFIG -= QwtDll. And as result I have libqwt.a (instead of libqwt-5.2.so). Static library. While compiling and installing no any problems. I`ve copied lib and src subdirectory into qwt subdirectory of my project. While compiling project no any trouble. A trouble at linking!

    Qt Code:
    1. cd '/home/Andrei/Projects/Rados/RadosSeparatorQT' && LC_MESSAGES="C" LC_CTYPE="C" gmake -k
    2. linking RadosSeparatorQT (g++)
    3. /usr/bin/ld: cannot find -llibqwt
    4. collect2: ld returned 1 exit status
    5. gmake: *** [RadosSeparatorQT] Error 1
    6. gmake: Target `first' not remade because of errors.
    7. *** Exited with status: 2 ***
    To copy to clipboard, switch view to plain text mode 

    Why it can`t find library? A path to it is correct.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt examples

    Quote Originally Posted by 31512 View Post
    unix:LIBS += -L/qwt/lib -llibqwt
    It should be:

    unix:LIBS += -L/qwt/lib -lqwt

  8. #7
    Join Date
    Jun 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt examples

    Quote Originally Posted by jacek View Post
    It should be:

    unix:LIBS += -L/qwt/lib -lqwt
    My respect to you! It works! It must be admitted that, the truth is that I am old stupid monkey! Can you explain why it should be -L/qwt/lib -lqwt, but not -L/qwt/lib -llibqwt?

  9. #8
    Join Date
    Jun 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt examples

    All was good until I wrote
    Qt Code:
    1. WidgetFrameCommonView::WidgetFrameCommonView( QWidget *parent )
    2. : QWidget( parent )
    3. {
    4. setupUi( this );
    5.  
    6. QwtPlotHistogram *histogram = new QwtPlotHistogram();
    7. //histogram->setStyle(QwtPlotHistogram::Columns);
    8. //histogram->setPen(QPen(Qt::black));
    9. //histogram->setBrush(QBrush(Qt::gray));
    10. //histogram->attach(Plot);
    11. //Plot->replot();
    12.  
    13. CommonInfoPanel->SetBackGroundColor( Qt::lightGray );
    14. SeparatorsPanelsPanel->SetBackGroundColor( Qt::gray );
    15. gridLayout->setContentsMargins( 0, 0, 0, 0 );
    16. gridLayout->setSpacing( 0 );
    17. }
    To copy to clipboard, switch view to plain text mode 

    linking RadosSeparatorQT (g++)
    WidgetFrameCommonView.o: In function `WidgetFrameCommonView':
    /home/Andrei/Projects/Rados/RadosSeparatorQT/Frames/WidgetFrameCommonView.cpp:9: undefined reference to `QwtPlotHistogram::QwtPlotHistogram(QString const&)'
    /home/Andrei/Projects/Rados/RadosSeparatorQT/Frames/WidgetFrameCommonView.cpp:9: undefined reference to `QwtPlotHistogram::QwtPlotHistogram(QString const&)'
    collect2: ld returned 1 exit status
    gmake: *** [RadosSeparatorQT] Error 1
    gmake: Target `first' not remade because of errors.
    *** Exited with status: 2 ***

    Without
    Qt Code:
    1. QwtPlotHistogram *histogram = new QwtPlotHistogram();
    To copy to clipboard, switch view to plain text mode 
    linking is successful. As I understood class QwtPlotHistogram have some bugs?

    Qt Code:
    1. class QWT_EXPORT QwtPlotHistogram: public QwtPlotSeriesItem<QwtIntervalSample>
    2. {
    3. public:
    4. enum CurveStyle
    5. {
    6. NoCurve,
    7.  
    8. Outline,
    9.  
    10. Columns,
    11. Lines,
    12.  
    13. UserCurve = 100
    14. };
    15.  
    16. explicit QwtPlotHistogram(const QString &title = QString::null);
    17. explicit QwtPlotHistogram(const QwtText &title);
    18. virtual ~QwtPlotHistogram();
    19.  
    20. ...
    21. };
    22. #endif
    To copy to clipboard, switch view to plain text mode 

  10. #9
    Join Date
    Jun 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt examples

    Histogram example was compiled and linked successfully. Executed successfully too. I`m perplexed... My program still generating link errors.
    Last edited by 31512; 2nd July 2008 at 10:54.

  11. #10
    Join Date
    Jun 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt examples

    OK. Problem solved successfully. Including examples.pri (with some modifications) to *.pro file of my project makes wonder...

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qwt examples

    Quote Originally Posted by 31512 View Post
    Can you explain why it should be -L/qwt/lib -lqwt, but not -L/qwt/lib -llibqwt?
    It's UNIX naming convention. All library file names start with "lib", so somebody in the Olde Days decided to skip it in linker options.

  13. #12
    Join Date
    Jun 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt examples

    Quote Originally Posted by jacek View Post
    It's UNIX naming convention. All library file names start with "lib", so somebody in the Olde Days decided to skip it in linker options.
    Thanks a lot! Live and learn... RTFM for me.

Similar Threads

  1. Qwt examples
    By nitriles in forum Qwt
    Replies: 7
    Last Post: 6th August 2011, 04:07
  2. Replies: 7
    Last Post: 9th May 2009, 22:31
  3. QWT introduction
    By nitriles in forum Qwt
    Replies: 4
    Last Post: 28th September 2007, 10:48
  4. How to upgrade Qwt 5.0.1 to Qwt 5.0.2
    By luffy27 in forum Qwt
    Replies: 1
    Last Post: 15th July 2007, 19:55
  5. use interesting QWT Library with QT3.X
    By raphaelf in forum Qwt
    Replies: 2
    Last Post: 23rd January 2006, 11:24

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.