PDA

View Full Version : Problems with SetMajPen after upgrading QT to 4.8.4 and QWT6.1



KenJustKen
5th April 2013, 03:57
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






#include "plot.h"
// include "friedberg2007.h"
#include <qwt_plot_zoomer.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_marker.h>
#include <qwt_plot_grid.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_intervalcurve.h>
#include <qwt_legend.h>
#include <qwt_interval_symbol.h>
#include <qwt_symbol.h>
#include <qwt_series_data.h>
#include <qwt_text.h>
#include <qwt_scale_draw.h>
#include <qwt_plot_renderer.h>
#include <qdatetime.h>
#include <qfiledialog.h>
#include <qimagewriter.h>
#include <qprintdialog.h>
#include <qfileinfo.h>

...
...
...

class Grid: public QwtPlotGrid
{
public:
Grid()
{
enableXMin( true );
setMajPen( QPen( Qt::white, 0, Qt::DotLine ) );
setMinPen( QPen( Qt::gray, 0 , Qt::DotLine ) );
}


virtual void updateScaleDiv( const QwtScaleDiv &xMap,
const QwtScaleDiv &yMap )
{
QList<double> ticks[QwtScaleDiv::NTickTypes];

ticks[QwtScaleDiv::MajorTick] =
xMap.ticks( QwtScaleDiv::MediumTick );
ticks[QwtScaleDiv::MinorTick] =
xMap.ticks( QwtScaleDiv::MinorTick );

QwtPlotGrid::updateScaleDiv(
QwtScaleDiv( xMap.lowerBound(), xMap.upperBound(), ticks ),
yMap );
}
};

Uwe
5th April 2013, 06:56
/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

KenJustKen
8th April 2013, 17:40
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.

8899

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.

KenJustKen
9th April 2013, 14:14
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'



Plot::Plot( QString Title, QString YLabel, double minY, double maxY, QWidget * parent):
QwtPlot( parent )
{

setObjectName( "TempPlot" );
setTitle( Title );

setAxisScaleDraw( QwtPlot::xBottom, new YearScaleDraw() );

setAxisTitle( QwtPlot::yLeft, YLabel);

setAxisScale(QwtPlot::yLeft,minY,maxY,0);

setAutoReplot(true);

// grid
QwtPlotGrid *grid = new Grid;
grid->attach( this );

//insertLegend( new QwtLegend(), QwtPlot::RightLegend );

d_curve = new QwtPlotCurve( Title );
d_curve->setRenderHint( QwtPlotItem::RenderAntialiased );
d_curve->setStyle( QwtPlotCurve::Lines );//kls
d_curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol );
d_curve->setData( new CurveData() );
d_curve->attach( this );


// LeftButton for the zooming
// MidButton for the panning
// RightButton: zoom out by 1
// Ctrl+RighButton: zoom out to full size

//QwtPlotZoomer* zoomer = new QwtPlotZoomer( canvas() );
zoomer = new QwtPlotZoomer( canvas() );
zoomer->setRubberBandPen( QColor( Qt::black ) );
zoomer->setTrackerPen( QColor( Qt::black ) );
zoomer->setMousePattern( QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier );
zoomer->setMousePattern( QwtEventPattern::MouseSelect3,
Qt::RightButton );

QwtPlotPanner *panner = new QwtPlotPanner( canvas() );
panner->setMouseButton( Qt::MidButton );

canvas()->setPalette( Qt::darkGray );
canvas()->setBorderRadius( 10.0 );

connect(zoomer, SIGNAL(zoomed(const QRectF&)), this, SLOT(DoZoom( QRectF )));


}

Uwe
9th April 2013, 14:29
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:


QwtPlotCanvas canvas = new QwtPlotCanvas();
canvas->setXY( ... );
...

plot->setCanvas( canvas );


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

KenJustKen
11th April 2013, 04:40
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 );