Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Q_ARG and templates



  • It is very difficult to work reasonably with Q_ARG and Q_RETURN_ARG when having template types. In the end I had to use meta-function for naming types like:

    @template< typename T >
    class TypeQtName;

    #define MAKE_TYPEQTNAME( T )
    template<>
    class TypeQtName< T >
    {
    public:
    static const char* const get()
    {
    return #T;
    }
    }; \

    MAKE_TYPEQTNAME( bool )
    /* ... */@

    But this approach is far from being elegant.

    What I think could be useful is to extend Qt so that it could locally deal with typeid result (the std::type_info class). That is not portable even across two executions of the same program in the same environment. But within a single execution it is and that does cover lots of cases.

    What do you think about it?


Log in to reply