Results 1 to 3 of 3

Thread: QWidget: Must construct a QApplication before a QPaintDevice

  1. #1
    Join Date
    Jul 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QWidget: Must construct a QApplication before a QPaintDevice

    Hello all,

    I am using qwt 6.0.0 with Qt 4.6.2 and I am getting the error "QWidget: Must construct a QApplication before a QPaintDevice." I searched the forum and see that other users have had similar error and the replies suggested are 1. debug/release compilation modes 2. static/dynamic library. I have tried these options suggested in the forum but I am not able to get rid of this error. In my case either in debug or release mode, I get the same error. My code is very simple - plotting a sine plot using qwt:

    #include <iostream>
    #include <fstream>
    #include <string>

    #include <QApplication>
    #include <QDialog>
    #include <QPushButton>
    #include <QString>
    #include <QFileInfo>
    #include <QMainWindow>
    #include <qwt_plot.h>
    #include <qwt_plot_curve.h>

    int main(int argc, char *argv[])
    {

    QApplication app(argc, argv);

    QwtPlot plot(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 sine101;

    std::vector<double> xs;
    std::vector<double> ys;
    for (double x1 = 0; x1 < 2.0 * M_PI; x1+=(M_PI / 10.0))
    {
    xs.push_back(x1);
    ys.push_back(std::sin(x1));
    }
    sine101.setSamples(&xs[0],&ys[0],xs.size());
    sine101.attach(&plot);

    plot.show();
    return app.exec();
    }

    Any help will be appreciated.

    Thanks.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QWidget: Must construct a QApplication before a QPaintDevice

    I couldn't think of anything why it should give such error, even after creating QApplication. I tried creating the same project on my machine with Qt 4.7.0, Qwt 6.0.0, it just works. But I had to do one modification, I had to add #include <cmath> to the source posted my you. Further here is my project file, and screen shot for reference.

    Qt Code:
    1. include(C:/qwt-6.0.0/examples/examples.pri)
    2.  
    3. QT += core gui
    4.  
    5. TARGET = untitled
    6. TEMPLATE = app
    7. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  3. #3
    Join Date
    Jul 2010
    Posts
    7
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: QWidget: Must construct a QApplication before a QPaintDevice

    Hey,

    I am trying to build qwt app in Qt usinf Nokia Qt SDK, But it gives the following error:

    :: error: No rule to make target `\NokiaQtSDK\Symbian\SDK\epoc32\release\armv5\LIB\ qwt.dso', needed by `\NokiaQtSDK\Symbian\SDK\epoc32\release\gcce\udeb\ HRMGraphApp.exe'. Stop.
    Any ideas hiw to resolve this problem.

    Thanks in advance...

Similar Threads

  1. Replies: 16
    Last Post: 12th December 2014, 20:22
  2. Replies: 0
    Last Post: 20th April 2009, 17:45
  3. Replies: 1
    Last Post: 8th January 2009, 13:36
  4. Must construct QApplication before QPaintDevice
    By sekatsim in forum Qt Programming
    Replies: 16
    Last Post: 8th June 2008, 00:00
  5. Replies: 15
    Last Post: 21st April 2007, 17:46

Tags for this Thread

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.