Do I need to recompile qmake with the exceptions, rtti and stl flags to get dynamic_cast to work with QT? I'm using Visual C++ 2005 and the /GR flag is enabled (by default).

I'm asking because have implemented a simple Composite Pattern and I need to find out whether the Component is a Leaf or a Composite. This is what I would like to do:
Qt Code:
  1. try
  2. {
  3. Leaf* leaf = dynamic_cast<Leaf*>(component);
  4. //A Leaf
  5. }
  6. catch (std::bad_cast e)
  7. {
  8. //Not a Leaf
  9. }
To copy to clipboard, switch view to plain text mode 
However, in practice the exception is never thrown and the program dies because of memory access violations.