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
Code:
#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>
...
...
...
{
public:
Grid()
{
enableXMin( true );
setMajPen
( QPen( Qt
::white,
0, Qt
::DotLine ) );
setMinPen
( QPen( Qt
::gray,
0 , Qt
::DotLine ) );
}
{
QwtScaleDiv( xMap.
lowerBound(), xMap.
upperBound(), ticks
),
yMap );
}
};
Re: Problems with SetMajPen after upgrading QT to 4.8.4 and QWT6.1
Quote:
Originally Posted by
KenJustKen
/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
1 Attachment(s)
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.
Attachment 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.
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'
Code:
{
setObjectName( "TempPlot" );
setTitle( Title );
setAxisScaleDraw
( QwtPlot::xBottom,
new YearScaleDraw
() );
setAxisTitle
( QwtPlot::yLeft, YLabel
);
setAxisScale
(QwtPlot::yLeft,minY,maxY,
0);
setAutoReplot(true);
// grid
grid->attach( this );
//insertLegend( new QwtLegend(), QwtPlot::RightLegend );
d_curve
->setRenderHint
( QwtPlotItem::RenderAntialiased );
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
->setRubberBandPen
( QColor( Qt
::black ) );
zoomer
->setTrackerPen
( QColor( Qt
::black ) );
Qt::RightButton, Qt::ControlModifier );
Qt::RightButton );
panner->setMouseButton( Qt::MidButton );
canvas()->setPalette( Qt::darkGray );
canvas()->setBorderRadius( 10.0 );
connect(zoomer,
SIGNAL(zoomed
(const QRectF
&)),
this,
SLOT(DoZoom
( QRectF )));
}
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:
Code:
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
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 );