Qt: typeid alternative

Viewed 4358

I'm wondering if Qt provides an alternative to typeid to recognize variable types and get their name in a human-readable format. My specific problem is the following:

struct gArgument{
    QString type; 
    void* arg;
};

void gargConverter(gArgument* oArg, T data){
    oArg->type = typeid(data).name();
    oArg->arg = static_cast<void*> (&data);
}

the idea would be that of generalizing a variable to use as a input to functions. As a side node tyeinfo seems not to be working correctly on my system (I'm using MinGW on Windows 7), if I try:

  int i; std::cout <<   typeid(i).name() << std::endl;
  QString s; std::cout <<   typeid(s).name() << std::endl;
  double d; std::cout <<   typeid(d).name() << std::endl;
  float f; std::cout <<   typeid(f).name() << std::endl;

I get

i
7QString
d
f

Any suggestion?

3 Answers
Related