[Interest] QwtPlot in QGridLayout
David Boosalis
david.boosalis at gmail.com
Sat May 5 01:06:11 CEST 2012
Issues with your code that I see:
1) It will not compile as is
2) you do not have and connect for addChartPB::clicked() and your slot
addChart().
I would advise you not use QWT to debug your code, but just use labels
instead.
On Thu, May 3, 2012 at 2:24 AM, Sujan Dasmahapatra <sdh at lmwindpower.com>wrote:
> I want to create a some plots on the QGridLayout. ****
>
> I have a QWidget which has a pushbutton and another QWidget called canvas.
> ****
>
> In the canvas I have a QGridLayout.****
>
> When user presses the pushbutton it should create a QWidget and this
> widget will have my plot and a legend. They will be appended in 2 columns
> and multiple rows.****
>
> ** **
>
> //please check this code snippet****
>
> ** **
>
> //sheet.h****
>
> class CSheet : public QWidget****
>
> {****
>
> Q_OBJECT****
>
> Public:****
>
> CSheet(QWidget *parent=0);****
>
> ~CSheet();****
>
> QWidget *canvas;****
>
> QPushButton *addChartPB;****
>
> QGridLayout *layout;****
>
> ** **
>
> QList <QWidget *> plotWidgets;****
>
> QList <QwtPlot *> plots;****
>
> QList <QWidget *> legends;****
>
> ** **
>
> int row, column;****
>
> ** **
>
> private slots:****
>
> void addChart();****
>
> ** **
>
> };****
>
> ** **
>
> //sheet.cpp****
>
> ** **
>
> CSheet::CSheet(QWidget *parent):QWidget(parent), row(0), column(0)****
>
> {****
>
> setGeometry(0,0,800,600); ****
>
> ** **
>
> addChartPB = new QWidget(“Add chart”, this);****
>
> addChartPB->setGeometry(5,5,100,25);****
>
> addChartPB->show();****
>
> ** **
>
> canvas = new QWidget(this);****
>
> canvas->setGeometry(5,35,width()-10, height()-40);****
>
> canvas->show();****
>
> ****
>
> layout = new QGridLayout(canvas);****
>
> canvas->setLayout(layout);****
>
> }****
>
> ** **
>
> CSheet::~CSheet()****
>
> {****
>
> } ****
>
> ** **
>
> void CSheet::addChart()****
>
> {****
>
> plotWidgets.append(new QWidget(canvas));****
>
> ** **
>
> plots.append(new QwtPlot(plotWidgets.last()));****
>
> ** **
>
> legends.append(new QWidget(plotWidgets.last()));****
>
> ** **
>
> layout->addWidget(plotWidgets.last(), row, column);****
>
> ** **
>
> if(column==0)****
>
> column++;****
>
> else****
>
> column--; ****
>
> if(plotsWidgets.count()%2==0)****
>
> row++;****
>
> }****
>
> ** **
>
> ** **
>
> With this piece of code my plots and legends nothing is visible. Can
> anyone help in getting whats going wrong in this. Thanks a lot Sujan****
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120504/5cd05dd5/attachment.html>
More information about the Interest
mailing list