[Solved]Align scrollbar
-
Is there anyone who can in a simple way explain how I could align a Scrollbar to a QWT Plot widget.
I have tried with a scrollbar and a scrollarea but nothing works.Maybe someone have done this and got a smaller example.
pls
-
You can set the QWT plot widget as the widget for a QScrollArea using QScrollArea::setWidget. Note that it is up to you to make sure the plot widget then has the needed size.
-
Yes I tried that but if I set the setWidget(QWtplot)
the plotter area(Canvas) disappers.I'm a very newbee on this so I need some help
-
Show us the code then.
-
The code where I set Up the plot
@ ui->qwtPlot->setAxisScale(0,0,310,50);
ui->qwtPlot->setCanvasBackground(QBrush(Qt::white));ui->qwtPlot->setTitle("Power"); ui->qwtPlot->setAxisMaxMinor(2,0); //ui->qwtPlot->plotLayout()->setAlignCanvasToScales(true); ui->qwtPlot->setAxisTitle(0,"[kw]"); ui->qwtPlot->setAxisTitle(2,"Time [Sec]");
// panner = new QwtPanner(ui->qwtPlot->canvas());
ui->qwtPlot->canvas()->setPaintAttribute(QwtPlotCanvas::BackingStore,false);ui->qwtPlot->canvas()->setBaseSize(490,271); scrollArea = new QScrollArea(); scrollArea->setBackgroundRole(QPalette::Window); scrollArea->setWidget(ui->qwtPlot->canvas()); scrollArea->setAlignment(Qt::AlignBottom);
@
-
Qwt comes with a set of examples. In the realtime example you find a class ScrollZoomer, that adds scrollbars depending on the zoom base and the current zoom rectangle.
Adopting this class shoudln't be too difficult, but the code above that will never work as it breaks the layout code of QwtPlot and changes the parent/child relation of QwtPlot and its canvas.
Uwe
-
OK thanks Uwe
Maybe I can reach my goal if I use the panner in qwt?