Newbie: putting a QwtPlot on a ui form
A simple application with a ui form, generated in eclipse. I am working with Qt for about 6 months now, but still learning. The form is opened and shown after compiling. The form has a QWidget called "widget".
If I add the basic code to draw a qwtplot on the form it crashes. The mesage is: "QWidget: Must construct a QApplication before a QPaintDevice". I thought qapplication was constructed first in the main code, so I don't get it! I have tried linking the qwtplot to "this" and "parent" but the same result. I have also tried to move the plot from the constructor of class trygraph to a button press function but with the same result
In all examples of QwtPLot I can find the plot is made in the main function before "return a.exec();"
Appreciate any help or pointers to examples.
Code:
trygraph
::trygraph(QWidget *parent
){
ui.setupUi(this);
double x[100], y1[100];
for (int i = 0; i < 100; i++)
{
x[i] = i;
y1[i] = 10-0.1*i*i;
}
// add curves
// copy the data into the curves
curve1->setData(x,y1,100);
curve1->attach(myPlot);
myPlot->replot();
}
[the main function:]
int main(int argc, char *argv[])
{
trygraph w;
w.show();
return a.exec();
}
Re: Newbie: putting a QwtPlot on a ui form
Hello,
Be sure you're using the debug dll when you're in debug mode and the release one when you're in release mode. Review the compilation of the libraries.
Regards
Re: Newbie: putting a QwtPlot on a ui form
thanks, you mean my code should work?
I have compiled in debug mode but I'll check
Re: Newbie: putting a QwtPlot on a ui form
Yes, I think your code will work.
Try to give a look at your compilation of the dll.
Regards.
Re: Newbie: putting a QwtPlot on a ui form
that was it!
thanks a lot ;-)