Results 1 to 3 of 3

Thread: QwtPlot on ui form

  1. #1
    Join Date
    Jul 2009
    Posts
    92
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QwtPlot on ui form

    A simple application with a ui form, generated in eclipse. The form is opened and shown upon 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 form the constructor of 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.

    Qt Code:
    1. trygraph::trygraph(QWidget *parent)
    2. : QWidget(parent)
    3. {
    4. ui.setupUi(this);
    5.  
    6. double x[100], y1[100];
    7. QwtPlot *myPlot = new QwtPlot(QwtText("a Curves"), ui.widget);
    8.  
    9. for (int i = 0; i < 100; i++)
    10. {
    11. x[i] = i;
    12. y1[i] = 10-0.1*i*i;
    13. }
    14.  
    15. // add curves
    16. QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
    17.  
    18. // copy the data into the curves
    19. curve1->setData(x,y1,100);
    20.  
    21. curve1->attach(myPlot);
    22.  
    23. myPlot->replot();
    24. }
    25.  
    26. [the main function:]
    27.  
    28. int main(int argc, char *argv[])
    29. {
    30. QApplication a(argc, argv);
    31. trygraph w;
    32. w.show();
    33. return a.exec();
    34. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by qt_gotcha; 4th June 2010 at 08:10.

  2. #2
    Join Date
    Jul 2009
    Posts
    92
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlot on ui form

    sorry didn't see the Qwt forum, asked it there

  3. #3
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlot on ui form

    hmm..

    i dont see the problem rigth now, maybe you debug it with F5 and post the line of error?
    greetz A.

Similar Threads

  1. Pass variable from a form to another form
    By dark1988 in forum Qt Programming
    Replies: 5
    Last Post: 8th February 2011, 18:19
  2. Replies: 5
    Last Post: 12th March 2010, 21:43
  3. Replies: 6
    Last Post: 14th May 2009, 12:02
  4. Help me to load one form over another form PushButton
    By wagmare in forum Qt Programming
    Replies: 7
    Last Post: 26th November 2008, 16:11
  5. Calling a new form from current form
    By webgenius in forum Qt Programming
    Replies: 7
    Last Post: 8th April 2007, 19:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.