typeid with Qt throws exception

G

Gil Grissom

Hi,

I have a problem with Qt and the use of the rtti features.

I compiled Qt and the included examples with the intel c++ compiler 8.1
like the following commands show:

icl -c -nologo -Zm200 -W3 -MD -GX -GX -GR -DUNICODE -DQT_DLL
-DQT_THREAD_SUPPORT -DQT_NO_DEBUG -I"C:\Qt\3.3.4\include" -I"."
-I"tmp\moc\release_mt_shared" -I"C:\Qt\3.3.4\mkspecs\win32-icc"
-Fotmp\obj\release_mt_shared\ @C:\DOKUME~1\user\LOKALE~1\Temp\nm84.tmp
main.cpp

link /NOLOGO delayimp.lib /DELAYLOAD:comdlg32.dll
/DELAYLOAD:eek:leaut32.dll /DELAYLOAD:winmm.dll /DELAYLOAD:wsock32.dll
/DELAYLOAD:winspool.dll /DELAYLOAD:eek:pengl32.dll /SUBSYSTEM:windows
/LIBPATH:"C:\Qt\3.3.4\lib" /OUT:aclock.exe
@C:\DOKUME~1\user\LOKALE~1\Temp\nm85.tmp

The examples aclock.exe works fine and the whole Qt lib as well.

Now I changed the code of main.cpp in the aclock example and added the
following lines:

QRadioButton *button = new QRadioButton(0,"TestButton");
char name[1024];
sprintf( name, "\"%s\" \"%s\" (\"%s\")",
button->name(), button->className(),
typeid( *button ).name() );
clock->setCaption(name);

The calls of typeid(*button) fails with the following message:

"Runtime Error!
...
This application has requested the Runtime to terminate it in an unusual
way. Please contact the application's support for more information."

But typeid(button) and typeid(*clock) work fine!

Whats wrong with this? What can I do?

Thanks in advance,
Gil
 
V

Victor Bazarov

Gil said:
I have a problem with Qt and the use of the rtti features.
[...]

Then go to their web site and read, or write to, their online
discussion forums. This newsgroup is about C++ _language_, not
about any particular product.

Are you sure your pointer is not null when you try to dereference
it when taking 'typeid' of it?

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top