ROOTQT Error - Must construct a QApplication

Hi ,

I am trying to use QT for root. And followed the instructions on QT ROOT web page and root tutorial.
Following the tutorial examples i.e. Qt Based ROOT application and ROOT based QT application. I can make the first one to work i…e using QT from root. But when executing ROOT from QT I get following message:

QPaintDevice: Must t construct a QApplication before a QPaintDevice

The following is my code and output from make

thanks
Asif

+++++++++++ start code +++++++++++++++++++++++++++++++
#include “qapplication.h”
#include “qlabel.h”
#include "TFile.h"
int main(int argc, char* argv[])
{

    QApplication app (argc, argv);
    QLabel *label = new QLabel("Hello QT", 0);
    app.setMainWidget(label);
                                                                                                 
    label->show();
    TFile f ("test.root","create");
    f.Close();
    return app.exec();

}
{ I also used the EXACT examples as in tutorial but that does not work either }

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

++++++++++++++ Make output +++++++++++++++++++++++++++++++++++++++
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/Libr ary/qt-x11-free-3.3.5/mkspecs/default -I. -I. -I"/Library/root/include" -I/Libra ry/qt-x11-free-3.3.5/include -o test.o test.cpp

g++ -Wl,-rpath,/Library/qt-x11-free-3.3.5/lib -o ex4 test.o -L/Library/qt-x11 -free-3.3.5/lib -L/usr/X11R6/lib -L/Library/root/lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -pthread -l dl -rdynamic -lGQt -lQtGui -lqt-mt -lXext -lX11 -lm

[quote=“asif”]Hi ,

I am trying to use QT for root. And followed the instructions on QT ROOT web page and root tutorial.
Following the tutorial examples i.e. Qt Based ROOT application and ROOT based QT application. I can make the first one to work i…e using QT from root. But when executing ROOT from QT I get following message:

QPaintDevice: Must t construct a QApplication before a QPaintDevice

The following is my code and output from make

thanks
Asif

+++++++++++ start code +++++++++++++++++++++++++++++++
#include “qapplication.h”
#include “qlabel.h”
#include "TFile.h"
int main(int argc, char* argv[])
{

    QApplication app (argc, argv);
    QLabel *label = new QLabel("Hello QT", 0);
    app.setMainWidget(label);
                                                                                                 
    label->show();
    TFile f ("test.root","create");
    f.Close();
    return app.exec();

}
{ I also used the EXACT examples as in tutorial but that does not work either }

g++ -Wl,-rpath,/Library/qt-x11-free-3.3.5/lib -o ex4 test.o -L/Library/qt-x11 -free-3.3.5/lib -L/usr/X11R6/lib -L/Library/root/lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -pthread -l dl -rdynamic -lGQt -lQtGui -lqt-mt -lXext -lX11 -lm[/quote]

You should not link against of QtGui shared library. This shared library will be loaded later automatically via ROOT Plug-in mechanizm. The presence of the library caused no problem till ROOT version 5.03 and was needed to link QtROOT on Mac platfrom. (The project file for my “Hello” example does remove the library from the linker list and MUST work. May be you have the older version)

I have changed the rootlibs.pri file (This is where the confusion came from) with BNL CVS Repository and shall propagate this correction to CERN Repository ASAP.