Results 1 to 7 of 7

Thread: Qwt and Qwtpolar : "Qwidget: Must construct a QApplication before a QWidget"

  1. #1
    Join Date
    Dec 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qwt and Qwtpolar : "Qwidget: Must construct a QApplication before a QWidget"

    Hi,
    I am just new to Qt programming and try to use both Qwt (6.1.1) and Qwtpolar (1.1.1) libs on windows XP under Qt5.2.1 (mingw48_32)
    On the hereafter example, the release version works properly but I can't make the debug version work.
    I've got the following message : "Qwidget: Must construct a QApplication before a QWidget"
    I've checked with the debugger that it fails when it tries to create the QwtPolarPlot instance.
    As the objects files are created within the ./debug directrory I know that the CONFIG test works fine
    and I properly refer to the debug libraries versions -- qwtd and qwtpolard --
    moreover, there are also properly referred in the Makefile.debug
    These libs were created with their default .pro files within QtCreator.

    Any idea ?


    The .cpp file

    MainWindow::MainWindow( QWidget *parent ):
    QMainWindow( parent )
    {
    m_pCentralWidget = new QWidget(this);
    setCentralWidget(m_pCentralWidget);

    m_pPolarGraph = new QwtPolarPlot(m_pCentralWidget);
    QGridLayout *pLayout = new QGridLayout(m_pCentralWidget);
    pLayout->addWidget(m_pPolarGraph, 1, 0);
    }


    int main( int argc, char **argv )
    {
    QApplication a( argc, argv );
    MainWindow mainWindow;
    mainWindow.show();
    return a.exec();
    }



    The .Pro file

    TARGET = trial1
    QT += widgets
    MOC_DIR = moc
    DEFINES += QWT_DLL QWT_POLAR_DLL

    QWT_ROOT = C:\LocalApplications\qwt-6.1.1
    QWT_LIBS = -L$${QWT_ROOT}\lib
    QWT_INCLUDES = $${QWT_ROOT}\src

    QWT_POLAR_ROOT = C:\LocalApplications\qwtpolar-1.1.1
    QWT_POLAR_LIBS = -L$${QWT_POLAR_ROOT}\lib
    QWT_POLAR_INCLUDES = $${QWT_POLAR_ROOT}\src

    INCLUDEPATH += $${QWT_POLAR_INCLUDES} $${QWT_INCLUDES}
    LIBS += $${QWT_LIBS} $${QWT_POLAR_LIBS}

    CONFIG(debug, debug|release) {
    DESTDIR = ./debug
    LIBS += -lqwtd -lqwtpolard
    OBJECTS_DIR =./debug
    } else {
    DESTDIR = ./release
    LIBS += -lqwt -lqwtpolar
    OBJECTS_DIR =./release
    }

    SOURCES += \
    main.cpp


  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,313
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt and Qwtpolar : "Qwidget: Must construct a QApplication before a QWidget"

    This message often indicates that you are mixing libs/apps build with release and debug.

    Uwe

  3. #3
    Join Date
    Dec 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qwt and Qwtpolar : "Qwidget: Must construct a QApplication before a QWidget"

    Hi Uwe,

    Thanks a lot for your reply. Following it, I checked with DepedencyWalker the dependencies of qwtpolard.dll and saw that
    it depended on qwt.dll (instead of qwtd.dll). The reason is the following : Previously, in order to compile the qwtpolar libraries
    under QtCreator I had to add qwt paths (lib and include) and library name to the qwtpolar/src/src.pro file and forgot to make
    the distinction between release and debug mode.

    When I do it in the right way (using CONFIG(debug, debug|release) ... ) it works perfectly : qwtpolard.dll depends on qwtd.dll
    and my application runs in both modes.

    The question is now : why do I have to add the dependencies to qwt (lib and include paths) when I try to compile qwtpolar
    whereas I use the default .pro files delivered with qwtpolar1.1.1 ?

    Thanks again.

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,313
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt and Qwtpolar : "Qwidget: Must construct a QApplication before a QWidget"

    You didn't install qwtpolar properly - instead you are trying to build against something left over in the build directory. Once having qwtpolar installed, you will see, that qwtpolar.prf ( CONFIG += qwtpolar ) is the one for building applications.
    Have a look at http://qwt.sourceforge.net/qwtinstall.html. The concepts are the same for qwtpolar then.

    Putting the sources of qwt and qwtpolar and your application into one project is not the officially supported way and then you have to be able to ship around those issues yourself.

    Uwe

  5. #5
    Join Date
    Dec 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qwt and Qwtpolar : "Qwidget: Must construct a QApplication before a QWidget"

    Ok I understand but I actually did not put the sources into a single project.
    • First : I downloaded qwt and used the qwt.pro file to generate qwt.dll and qwtd.dll (/lib directory)

    • Second : I downloaded qwtpolar and used the qwtpolar.pro file to generate qwt.dll and qwtd.dll (/lib directory) -- This is where I had to modify the qwtpolar/src/src.pro file to be able to go through compilation without errors (this is also where I must miss something ...)

    • Third : Once all dlls are generated, I created my own application (with its own sources) that uses both qwt and qwtpolar libraries.
      (In the previously given example I refer to the src directories of qwt and qwtpolar only to get an access to their headers, but I do
      not address directly their .cpp files in my application)


    Sorry I do it again since their are mistakes in the previous answer....

    Ok I understand but I actually did not put the sources into a single project.
    • First : I downloaded qwt and used the qwt.pro file to generate qwt.dll and qwtd.dll (/lib directory)

    • Second : I downloaded qwtpolar and used the qwtpolar.pro file to generate qwtpolar.dll and qwtpolard.dll (/lib directory) -- This is where I had to modify the qwtpolar/src/src.pro file to be able to go through compilation without errors (this is also where I must miss something ...)

    • Third : Once all dlls are generated, I created my own application (with its own sources) that uses both qwt and qwtpolar libraries.
      (In the previously given example I refer to the src directories of qwt and qwtpolar only to get an access to their headers, but I do
      not address directly their .cpp files in my application)

  6. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,313
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt and Qwtpolar : "Qwidget: Must construct a QApplication before a QWidget"

    Quote Originally Posted by plb29n View Post
    Ok I understand but I actually did not put the sources into a single project.
    • First : I downloaded qwt and used the qwt.pro file to generate qwt.dll and qwtd.dll (/lib directory)
    Next step would be to install qwt. Then building qwtpolar would be against the properly installed qwt - not against the source tree, where you have built qwt.

    Uwe

  7. The following user says thank you to Uwe for this useful post:

    plb29n (18th December 2014)

  8. #7
    Join Date
    Dec 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qwt and Qwtpolar : "Qwidget: Must construct a QApplication before a QWidget"

    Ok,
    Thanks a lot for your help Uwe.

Similar Threads

  1. Replies: 16
    Last Post: 12th December 2014, 20:22
  2. QWidget: Must construct a QApplication before a QWidget
    By Connailo in forum Qt Programming
    Replies: 1
    Last Post: 27th October 2014, 08:02
  3. Replies: 2
    Last Post: 25th July 2011, 08:08
  4. Replies: 0
    Last Post: 20th April 2009, 17:45
  5. Replies: 1
    Last Post: 8th January 2009, 13:36

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.