Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QWidget: Must construct a QApplication before a QPaintDevice



  • QWidget: Must construct a QApplication before a QPaintDevice

    Anyone know how to repair that problem.?
    I use Qwt library.



  • CONFIG += QwtDll this line must be ->
    #CONFIG += QwtDll

    from" here":http://www.qtcentre.org/threads/10959-QWidget-Must-construct-a-QApplication-before-a-QPaintDevice



  • This fix doesn't work.



  • I create action for button like this.
    <code>
    void MainWindow::buttonclickhandler()
    {
    QwtPlot *myPlot=new QwtPlot;
    QwtText title( "Two Curves" );

            QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
            double t[100];
            double y[100];
            for (int i=0;i<100;i++)
            {
                t[i]=i;
                y[i]=sin(2*20*i);
            }
            curve1->setRawSamples(t,y,100);
    

    curve1->attach(myPlot);
    myPlot->show();
    myPlot->replot();
    }
    </code>

    and when i Start compilate I get error like this: QWidget: Must construct a QApplication before a QPaintDevice



  • Anyone know how to repair that error.?



  • Patience is a virtue.

    Bumping your topic after one hour is most likely to annoy your fellow developers on the forum and make them stay away from your topic.

    Do as the error message suggests: construct a QApplication instance before creating any other widget.

    If you really did that, then it's most likely the you mix debug and release versions of your libraries.

    And you never get that error on compilation, but only during runtime.



  • I today had the same error. I fixed it by switching to release mode. Seems like I only got the libraries for the release version (using Windows 7 64 bit, Qt Designer using MSVC 2010 compiler).



  • [quote author="simplePlan" date="1345041060"]I today had the same error. I fixed it by switching to release mode. Seems like I only got the libraries for the release version (using Windows 7 64 bit, Qt Designer using MSVC 2010 compiler).[/quote]

    Worked for me. Thank you!


Log in to reply