Qt-based ROOT application

Dear all rooters!

    I'm here to ask your help to solve this nasty problem. I'm writing a GUI using (Qt) designer for my Root application. I followed the instructions in the documentation on how to build the root Dictionary, but when I run make I got a lot of errors also compiling the following very simple example:

// in file TProva.h
// -----------------------

#ifndef TPROVA_H
#define TPROVA_H

#include “Rtypes.h”
#include “qpushbutton.h”

class QPushButton;
class TVirtualPad;

class TProva {

private:
QPushButton * fMyButton;

public:
TProva();
virtual ~TProva();
};

#endif
// -------------------------------

// in file TProva.cxx
// ---------------------

#include “TProva.h”

TProva::TProva() {
fMyButton = new QPushButton(“prova”,0);
}

TProva::~TProva() { delete fMyButton; }
//…

// in file LinkDef.h
// -----------------------
#ifdef CINT

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class TProva;

#endif
// ----------------------------

// in file prova.pro
// --------------------
TEMPLATE = lib dll thread

HEADERS += TProva.h
SOURCES += TProva.cxx

CREATE_ROOT_DICT_FOR_CLASSES = ${HEADERS} LinkDef.h
include("$(ROOTSYS)/include/rootcint.pri")

// ------------------------------

when I type “qmake prova.pro” I got this warning

WARNING: Failure to find: Dict.cxx

and when I type “make” I got a lot of errors during the Dictionary (Dict.cxx) generation:

/cern/root/bin/rootcint -f Dict.cxx -c -I/usr/lib/qt-3.3/mkspecs/default -I. -I"/cern/root/include" -I/usr/lib/qt-3.3/include TProva.h LinkDef.h
Error: Illegal pointer operation (tovalue) /usr/lib/qt-3.3/include/qglobal.h:148:
Error: operator ‘/’ divided by zero /usr/lib/qt-3.3/include/qglobal.h:148:
Syntax Error: defined(_SCO_DS)/SCOOpenServer5+GCC/ /usr/lib/qt-3.3/include/qglobal.h:148:
Error: Illegal pointer operation (tovalue) /usr/lib/qt-3.3/include/qglobal.h:150:
Error: operator ‘/’ divided by zero /usr/lib/qt-3.3/include/qglobal.h:150:
Syntax Error: defined(USLC)/allSCOplatforms+UDKorOUDK/ /usr/lib/qt-3.3/include/qglobal.h:150:


Limitation: length of one function argument be less than 1024 /usr/lib/qt-3.3/include/qstring.h:751:
Use temp variable as workaround.
Error: improper lvalue /usr/lib/qt-3.3/include/qstring.h:751:
make: *** [Dict.cxx] Segmentation fault
make: *** Deleting file `Dict.cxx’

Can you tell me something? I’m using Root v5-10-0 and Qt-3-3-4.

Thanks in advance…

Antonio

Hi Antonio,
this problem has been fixed in the current development release 5.11/02.
Axel.

I’ll try immediately and let you know… thanks!

cheers

antonio

Dear Axel,
thanks for the quick reply. I tried with the development version but with no luck! I’ve read in the Release note that there is a new (big) library of rootcint for Qt dictionary. I compiled it, but I don’t know how to use it…

Anything else? Thanks again…

That’s again the output of rootcint

/cern/root/bin/rootcint -f Dict.cxx -c -DQT_VERSION=0x30000 -I/usr/lib/qt-3.3/mkspecs/default -I. -I"/cern/root/include" -I/usr/lib/qt-3.3/include TProva.h LinkDef.h
#error "Qt has not been ported to this OS - talk to qt-bugs@trolltech.com"
Error: Function :data(0) is not defined in current scope /usr/lib/qt-3.3/include/qgarray.h:116:
Error: Symbol {}char is not defined in current scope /usr/lib/qt-3.3/include/qgarray.h:116:
Error: Function len(0){}char is not defined in current scope /usr/lib/qt-3.3/include/qgarray.h:116:
Error: Function data;uintlen;};QGArray( is not defined in current scope /usr/lib/qt-3.3/include/qgarray.h:116:
Limitation: length of one function argument be less than 1024 /usr/lib/qt-3.3/include/qgarray.h:116:
Use temp variable as workaround.
Error: improper lvalue /usr/lib/qt-3.3/include/qgarray.h:116:
Error: class,struct,union or type QGArray not defined /usr/lib/qt-3.3/include/qgarray.h:119:
Error: class,struct,union or type QGArray not defined /usr/lib/qt-3.3/include/qmemarray.h:48:
Error: Unexpected EOF G__fignorestream():3 /usr/lib/qt-3.3/include/qcstring.h:390:
Advice: You may need to use +P or -p option
Limitation: length of one function argument be less than 1024 /usr/lib/qt-3.3/include/qstring.h:244:
Use temp variable as workaround.
Error: improper lvalue /usr/lib/qt-3.3/include/qstring.h:244:
Error: class,struct,union or type QChar not defined /usr/lib/qt-3.3/include/qstring.h:246:
Error: class,struct,union or type QChar not defined /usr/lib/qt-3.3/include/qstring.h:252:
Error: class,struct,union or type QChar not defined /usr/lib/qt-3.3/include/qstring.h:258:
Error: class,struct,union or type QChar not defined /usr/lib/qt-3.3/include/qstring.h:264:
Error: class,struct,union or type QChar not defined /usr/lib/qt-3.3/include/qstring.h:270:
Error: class,struct,union or type QChar not defined /usr/lib/qt-3.3/include/qstring.h:277:
Error: class,struct,union or type QChar not defined /usr/lib/qt-3.3/include/qstring.h:283:
Error: class,struct,union or type QChar not defined /usr/lib/qt-3.3/include/qstring.h:289:
Error: class,struct,union or type QChar not defined /usr/lib/qt-3.3/include/qstring.h:295:
Error: Function {}~QStringData(){if(unicode)delete;if(ascii)delete[]ascii;}voiddeleteSelf();QChar is not defined in current scope /usr/lib/qt-3.3/include/qstring.h:394:
Error: Function islatin1(FALSE){}~QStringData(){if(unicode)delete;if(ascii)delete[]ascii;}voiddeleteSelf();QChar is not defined in current scope /usr/lib/qt-3.3/include/qstring.h:394:
Error: Symbol unicode;char is not defined in current scope /usr/lib/qt-3.3/include/qstring.h:394:
Error: Function ascii;voidsetDirty(){if(ascii){delete[]ascii;ascii=0;}issimpletext=FALSE;}uintlen:30;uintissimpletext:1;uintmaxl:30;uintislatin1:1;private:QStringData(constQStringData&);QStringData is not defined in current scope /usr/lib/qt-3.3/include/qstring.h:394:
Error: Symbol ;} is not defined in current scope /usr/lib/qt-3.3/include/qstring.h:394:
Error: class,struct,union or type QStringData not defined /usr/lib/qt-3.3/include/qstring.h:394:
Error: Function {}~QStringData(){if(unicode)delete;if(ascii)delete[]ascii;}voiddeleteSelf();QChar is not defined in current scope /usr/lib/qt-3.3/include/qstring.h:394:
Error: Symbol unicode;char is not defined in current scope /usr/lib/qt-3.3/include/qstring.h:394:
Error: Function ascii;voidsetDirty(){if(ascii){delete[]ascii;ascii=0;}issimpletext=FALSE;}uintlen:30;uintissimpletext:1;uintmaxl:30;uintislatin1:1;private:QStringData(constQStringData&);QStringData is not defined in current scope /usr/lib/qt-3.3/include/qstring.h:394:
Error: Symbol operator is not defined in current scope /usr/lib/qt-3.3/include/qstring.h:394:
Limitation: length of one function argument be less than 1024 /usr/lib/qt-3.3/include/qstring.h:751:
Use temp variable as workaround.
Error: improper lvalue /usr/lib/qt-3.3/include/qstring.h:751:
make: *** [Dict.cxx] Segmentation fault
make: *** Deleting file `Dict.cxx’

probably I understood why I got the problem but still I don’t know how to solve it.

It seems that in the header files (from which I want to generate the root Dict) there shouldn’t be any qt includes…

The problem is that, if my class is derived from a Qt object, I need to have an include there…

Do you have any ideas?

cheers…

antonio

[quote=“antonio”]Dear Axel,
thanks for the quick reply. I tried with the development version but with no luck! I’ve read in the Release note that there is a new (big) library of rootcint for Qt dictionary. I compiled it, but I don’t know how to use it…
[/quote]See: root.bnl.gov/QtRoot/htmldoc/src/ … log.C.html
and root.bnl.gov/QtRoot/htmldoc/src/ … log.C.html

The macro for this example can be found in the ROOT CVS
root.cern.ch/viewcvs/tutorials/Q … ortby=date
root.cern.ch/viewcvs/tutorials/Q … ortby=date

[quote] thanks for the quick reply. I tried with the development version but with no luck! I’ve read in the Release note that there is a new (big) library of rootcint for Qt dictionary. I compiled it, but I don’t know how to use it…

Anything else? Thanks again[/quote
:astonished:
It should work, I am going to reprouce your problem and let you know.

Dear Valeri thanks for your help…

It seems that rootcint is not able to produce the dictionary when there is a a qt include in it…

looking forward to try your suggestions…

Cheers,

antonio

I had a look a the two examples you suggested me, but those are for using QClasses during an interactive root session. In my case I would like to have a class derived from, for example, QMainWindow, and to produce its dictionary…

Cheers,

antonio

[quote=“antonio”]Dear Valeri thanks for your help…

It seems that rootcint is not able to produce the dictionary when there is a a qt include in it…

looking forward to try your suggestions…

Cheers,

antonio[/quote]
I have tested your macro at CERN lxplus cluster with
[lxplus001] ~/ROOT/expert/RootTalk > echo $ROOTSYS
/afs/cern.ch/sw/lcg/external/root/5.10.00b/slc3_gcc323/root

Please, find the tar file with the working version of your example
( I have added the method Show to show your button :slight_smile:
[lxplus001] ~/ROOT/expert/RootTalk > tar -czvf prova.tar.gz 22.04.2006/
22.04.2006/
22.04.2006/prova.qmake.log
22.04.2006/LinkDef.h
22.04.2006/prova.pro
22.04.2006/prova.make.log
22.04.2006/TProva.h
22.04.2006/TProva.cxx
22.04.2006/.rootrc
22.04.2006/Prova.C
prova.tar.gz (1.22 KB)

sorry Valeri,
but probably I’ve said it wrong… I don’t want to use it from a root interactive shell.

I’m creating a Qt (stand-alone) application that is calling some root-derived classes that I wrote. The main problem is that, even if my classes derive from the TGObject, I’m not able to connect emitted signals to my Qt application slots. For this purpose, I’d like to create the root dictionary as reported in the documentation, but this fails because the class I want to create the dictionary is derived from QMainWindow and I have to include qmainwindow.h in the header file.

Also in your example, if you move #include “qpushbutton.h” from TProva.cxx to TProva.h you will not be able to produce the Dict.cxx.

I hope it’s a bit more clear now… sorry!

cheers

antonio

[quote=“antonio”]sorry Valeri,
but probably I’ve said it wrong… I don’t want to use it from a root interactive shell.
[/quote]
Why do you :unamused: need the RootCint dictionary then?

[quote=“antonio”]
I’m creating a Qt (stand-alone) application that is calling some root-derived classes that I wrote. The main problem is that, even if my classes derive from the TGObject,[/quote]
You example doesn’t show that yet.
Why do you need to derive from TGObject. To use Qt communication you need to derive your class from QObject (QWidget).

On the other hand I have plenty of examples those use ROOT signal / Qt slot commuication (see qtRoot/qtged package) and versa verse.

[quote=“antonio”]
I’m not able to connect emitted signals to my Qt application slots. For this purpose, I’d like to create the root dictionary as reported in the documentation, but this fails because the class I want to create the dictionary is derived from QMainWindow and I have to include qmainwindow.h in the header file.[/quote]

Please, show me your REAL example manifesting your problem.

[quote=“antonio”]
Also in your example, if you move #include “qpushbutton.h” from TProva.cxx to TProva.h you will not be able to produce the Dict.cxx.[/quote]
Well there is some CINT constrain. However you do not need that header file in your interface at all to get it work (see header files from qtRoot packages to learn the possible workarounds)

[quote=“antonio”]
I hope it’s a bit more clear now… sorry![/quote]
Not… really :blush: / However I am willing to assiste you to achieve your goal, I have to know your goal then :wink:

May I ask you to review root.bnl.gov/QtRoot/README_Hello_Example and tell me what your “use case” is?
Please, send me your real-life example (may be via normal E-mail or via lists.bnl.gov/pipermail/qt-root-l/ to avoid the RootForum pollution.

ok… I’m writing you a mail…

Thanks a lot

Cheers,

antonio