View Full Version : size of QWTplot without axes.
Hello,
can someone tell me, how can i get a size of QWTPlot without axes?
Thanks.
raphael.lencrerot
28th May 2013, 15:22
Ask for canvas size which is a widget:
http://qwt.sourceforge.net/class_qwt_plot.html#aafcc82150034fbeb393ceb9f54ba2 f1a
Thanks for your answer. I tested it successfully, but one thing I don't understand. If you look at the following example
#include <cmath>
#include <iostream>
#include <QApplication>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_series_data.h>
#include <qwt_point_data.h>
int main(int argc, char **argv)
{
QApplication a(argc, argv);
QwtPlot * plot=new QwtPlot(QwtText("CppQwtExample1"));
plot->setGeometry(0,0,640,400);
plot->setAxisScale(QwtPlot::xBottom, 0.0,2.0 * M_PI);
plot->setAxisScale(QwtPlot::yLeft,-1.0,1.0);
QwtPlotCurve curve("Sine");
std::vector<double> xs;
std::vector<double> ys;
for (double x = 0; x < 2.0 * M_PI; x+=(M_PI / 10.0))
{
xs.push_back(x);
ys.push_back(std::sin(x));
}
QwtPointArrayData * const data = new QwtPointArrayData(&xs[0],&ys[0],xs.size());
curve.setData(data);
curve.attach(plot);
QList<QRect> * dummy=new QList<QRect>;
dummy->append(plot->canvas()->geometry());
dummy->append(plot->geometry());
plot->show();
return a.exec();
}
then I get for the geometry from the parent widget a size of 640X480 and the size of canvas is 100X30, although the both widgets have the same size. Can someone it explain?
Thanks
Layout calculations are triggered by events, that are processed inside QApplication::exec(). The geometries you are collecting in your list are pointless - too early.
Uwe
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.