MickyJhon
24th January 2014, 17:36
hi, all.
i meet a problem with setAxisScale . when i use setAxisScale to set xTop axis , it can't work as i expect ,however , when i set xBottom , it works fine..
I try to change the curve by setting the xTop axis ,but the curve can't change! the code is as follow:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->qwtPlot->setCanvasBackground( Qt::white );
ui->qwtPlot->enableAxis(QwtPlot::xBottom,false);
ui->qwtPlot->enableAxis(QwtPlot::xTop,true);
ui->qwtPlot->setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );
ui->qwtPlot->setAxisScale( QwtPlot::xTop, 0.0, 10.0 );
QwtPlotCurve *curve= new QwtPlotCurve();
curve->setPen( Qt::blue );
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
QPolygonF points;
points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 )
<< QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 )
<< QPointF( 4.0, 7.9 ) << QPointF( 5.0, 7.1 );
curve->setSamples( points );
curve->attach(ui->qwtPlot);
ui->qwtPlot->resize( 600, 400 );
}
however . i can set the xBottom AXIS scale and th program works well, the key part of code is as follow:
//ui->qwtPlot->enableAxis(QwtPlot::xBottom,false);
//ui->qwtPlot->enableAxis(QwtPlot::xTop,true);
ui->qwtPlot->setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );
ui->qwtPlot->setAxisScale( QwtPlot::xBottom, 0.0, 100.0 );
i want to know a way to set the xTop axis scale correctly ,can u help me?
Micky Jhon.
i meet a problem with setAxisScale . when i use setAxisScale to set xTop axis , it can't work as i expect ,however , when i set xBottom , it works fine..
I try to change the curve by setting the xTop axis ,but the curve can't change! the code is as follow:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->qwtPlot->setCanvasBackground( Qt::white );
ui->qwtPlot->enableAxis(QwtPlot::xBottom,false);
ui->qwtPlot->enableAxis(QwtPlot::xTop,true);
ui->qwtPlot->setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );
ui->qwtPlot->setAxisScale( QwtPlot::xTop, 0.0, 10.0 );
QwtPlotCurve *curve= new QwtPlotCurve();
curve->setPen( Qt::blue );
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
QPolygonF points;
points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 )
<< QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 )
<< QPointF( 4.0, 7.9 ) << QPointF( 5.0, 7.1 );
curve->setSamples( points );
curve->attach(ui->qwtPlot);
ui->qwtPlot->resize( 600, 400 );
}
however . i can set the xBottom AXIS scale and th program works well, the key part of code is as follow:
//ui->qwtPlot->enableAxis(QwtPlot::xBottom,false);
//ui->qwtPlot->enableAxis(QwtPlot::xTop,true);
ui->qwtPlot->setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );
ui->qwtPlot->setAxisScale( QwtPlot::xBottom, 0.0, 100.0 );
i want to know a way to set the xTop axis scale correctly ,can u help me?
Micky Jhon.