Results 1 to 6 of 6

Thread: Problems with SetMajPen after upgrading QT to 4.8.4 and QWT6.1

  1. #1
    Join Date
    Nov 2011
    Posts
    30
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Problems with SetMajPen after upgrading QT to 4.8.4 and QWT6.1

    I just reinstalled OSX to the latest and upgraded QT(4.74->4.8.4) and QWT(6.01->6.1). After getting my project to compile I can finally run my code if I comment out a couple of qwt calls that I don't understand. Below is my code. I am getting the following compile errors

    /Users/KenS/QT_Projects/ep1/plot.cpp:127: error: 'setMajPen' was not declared in this scope
    /Users/KenS/QT_Projects/ep1/plot.cpp:128: error: 'setMinPen' was not declared in this scope

    I did not get these errors before the upgrade. Does anyone have an idea of what I am doing wrong or what I could have not configured correctly when I rebuilt my machine?

    Ken


    Qt Code:
    1. #include "plot.h"
    2. // include "friedberg2007.h"
    3. #include <qwt_plot_zoomer.h>
    4. #include <qwt_plot_panner.h>
    5. #include <qwt_plot_marker.h>
    6. #include <qwt_plot_grid.h>
    7. #include <qwt_plot_curve.h>
    8. #include <qwt_plot_intervalcurve.h>
    9. #include <qwt_legend.h>
    10. #include <qwt_interval_symbol.h>
    11. #include <qwt_symbol.h>
    12. #include <qwt_series_data.h>
    13. #include <qwt_text.h>
    14. #include <qwt_scale_draw.h>
    15. #include <qwt_plot_renderer.h>
    16. #include <qdatetime.h>
    17. #include <qfiledialog.h>
    18. #include <qimagewriter.h>
    19. #include <qprintdialog.h>
    20. #include <qfileinfo.h>
    21.  
    22. ...
    23. ...
    24. ...
    25.  
    26. class Grid: public QwtPlotGrid
    27. {
    28. public:
    29. Grid()
    30. {
    31. enableXMin( true );
    32. setMajPen( QPen( Qt::white, 0, Qt::DotLine ) );
    33. setMinPen( QPen( Qt::gray, 0 , Qt::DotLine ) );
    34. }
    35.  
    36.  
    37. virtual void updateScaleDiv( const QwtScaleDiv &xMap,
    38. const QwtScaleDiv &yMap )
    39. {
    40. QList<double> ticks[QwtScaleDiv::NTickTypes];
    41.  
    42. ticks[QwtScaleDiv::MajorTick] =
    43. xMap.ticks( QwtScaleDiv::MediumTick );
    44. ticks[QwtScaleDiv::MinorTick] =
    45. xMap.ticks( QwtScaleDiv::MinorTick );
    46.  
    47. QwtPlotGrid::updateScaleDiv(
    48. QwtScaleDiv( xMap.lowerBound(), xMap.upperBound(), ticks ),
    49. yMap );
    50. }
    51. };
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Problems with SetMajPen after upgrading QT to 4.8.4 and QWT6.1

    Quote Originally Posted by KenJustKen View Post
    /Users/KenS/QT_Projects/ep1/plot.cpp:127: error: 'setMajPen' was not declared in this scope
    /Users/KenS/QT_Projects/ep1/plot.cpp:128: error: 'setMinPen' was not declared in this scope
    What about spending 5 seconds on reading the 6.1 class documentation of QwtPlotGrid ?

    Uwe

  3. #3
    Join Date
    Nov 2011
    Posts
    30
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: Problems with SetMajPen after upgrading QT to 4.8.4 and QWT6.1

    I don't see anything different for this version. There are two methods for this call. One with a pen and one with all of the pen parameters. Here is a screen shot of the docs.

    pen.jpg


    Added after 21 minutes:


    OK,
    I see the difference now after looking at the code and docs. Very subtle changes in the names for 6.1 compared to previous version. in 6.1 SetMajPen now is called SetMajorPen Will fix on my side and try tonight when I get home.
    Last edited by KenJustKen; 8th April 2013 at 17:40.

  4. #4
    Join Date
    Nov 2011
    Posts
    30
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: Problems with SetMajPen after upgrading QT to 4.8.4 and QWT6.1

    The SetMajorPen fixed this issue. I am now running into another difference between 6.01 and 6.1. canvas()->setBorderRadius( 10.0 ); is giving a compile error. However, canvas()->setPalette( Qt::darkGray ); is not. I have looked at the 6.1 docs and it says it is supported. The error I am getting is

    /Users/KenS/QT_Projects/eP1/plot.cpp:284: error: 'class QWidget' has no member named 'setBorderRadius'

    Qt Code:
    1. Plot::Plot( QString Title, QString YLabel, double minY, double maxY, QWidget * parent):
    2. QwtPlot( parent )
    3. {
    4.  
    5. setObjectName( "TempPlot" );
    6. setTitle( Title );
    7.  
    8. setAxisScaleDraw( QwtPlot::xBottom, new YearScaleDraw() );
    9.  
    10. setAxisTitle( QwtPlot::yLeft, YLabel);
    11.  
    12. setAxisScale(QwtPlot::yLeft,minY,maxY,0);
    13.  
    14. setAutoReplot(true);
    15.  
    16. // grid
    17. QwtPlotGrid *grid = new Grid;
    18. grid->attach( this );
    19.  
    20. //insertLegend( new QwtLegend(), QwtPlot::RightLegend );
    21.  
    22. d_curve = new QwtPlotCurve( Title );
    23. d_curve->setRenderHint( QwtPlotItem::RenderAntialiased );
    24. d_curve->setStyle( QwtPlotCurve::Lines );//kls
    25. d_curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol );
    26. d_curve->setData( new CurveData() );
    27. d_curve->attach( this );
    28.  
    29.  
    30. // LeftButton for the zooming
    31. // MidButton for the panning
    32. // RightButton: zoom out by 1
    33. // Ctrl+RighButton: zoom out to full size
    34.  
    35. //QwtPlotZoomer* zoomer = new QwtPlotZoomer( canvas() );
    36. zoomer = new QwtPlotZoomer( canvas() );
    37. zoomer->setRubberBandPen( QColor( Qt::black ) );
    38. zoomer->setTrackerPen( QColor( Qt::black ) );
    39. zoomer->setMousePattern( QwtEventPattern::MouseSelect2,
    40. Qt::RightButton, Qt::ControlModifier );
    41. zoomer->setMousePattern( QwtEventPattern::MouseSelect3,
    42. Qt::RightButton );
    43.  
    44. QwtPlotPanner *panner = new QwtPlotPanner( canvas() );
    45. panner->setMouseButton( Qt::MidButton );
    46.  
    47. canvas()->setPalette( Qt::darkGray );
    48. canvas()->setBorderRadius( 10.0 );
    49.  
    50. connect(zoomer, SIGNAL(zoomed(const QRectF&)), this, SLOT(DoZoom( QRectF )));
    51.  
    52.  
    53. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Problems with SetMajPen after upgrading QT to 4.8.4 and QWT6.1

    In Qwt 6.1 QwtPlot::canvas() returns a QWidget - not a QwtPlotCanvas. The reason for this change is, that it is possible to have a QwtPlotGLCanvas or a QwtPlotCanvas.

    You can use a cast, but I would expect that application code for Qwt 6.1 will be written like this:

    Qt Code:
    1. canvas->setXY( ... );
    2. ...
    3.  
    4. plot->setCanvas( canvas );
    To copy to clipboard, switch view to plain text mode 

    Note that this modification makes it possible to overload virtual methods of the canvas, f.e all kind of event handlers - what had to be done with event filtering before.

    Uwe

  6. #6
    Join Date
    Nov 2011
    Posts
    30
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: Problems with SetMajPen after upgrading QT to 4.8.4 and QWT6.1

    Thanks for the information. I would not have figured this out myself.


    I was able to get this to work. This is what I had to modify to make my code work. I tried to limit any change to my code to the bare minimum as I have a deadline to meet.

    Add
    #include <qwt_plot_canvas.h>

    QwtPlotCanvas *pPlotCanvas;

    Add/Change the code to this.
    pPlotCanvas=(QwtPlotCanvas*)canvas();
    pPlotCanvas->setBorderRadius( 10 );

Similar Threads

  1. Replies: 3
    Last Post: 21st May 2012, 17:55
  2. qwt6.0.1 legend problem
    By alainstgt in forum Qwt
    Replies: 3
    Last Post: 29th March 2012, 18:52
  3. Problems when Upgrading to V4.7.2 from v4.4.3
    By richardander in forum Qt Programming
    Replies: 2
    Last Post: 22nd April 2011, 23:15
  4. Replies: 1
    Last Post: 18th June 2010, 15:34
  5. Problems upgrading Qt3->Qt4, pkgconfig not happy
    By EricFowler in forum Installation and Deployment
    Replies: 3
    Last Post: 6th April 2008, 23:07

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.