Important: Please read the Qt Code of Conduct -

Qt5 signals and slots, "too many initializers" error

  • I'm porting my program to Qt5 but signals and slots stopped working. I have signals
    @void error(int code, QString msg, int line, QFile file);
    void warning(int code, QString msg, int line, QFile file);@
    and I'm trying to connect them to ErrorHandler class which has identical slots.
    If I use the Qt4-style-connect like
    @errHandler.connect(&codeGenerator, SIGNAL(error(int,QString,int,QFile
    )), SLOT(error(int,QString,int,QFile
    errHandler.connect(&codeGenerator, SIGNAL(warning(int,QString,int,QFile*)), SLOT(warning(int,QString,int,QFile*)));@
    I don't get any warnings or errors. They just dont work. Emiting error signal in CodeGenerator doesn't cause calling of the error slot in ErrorHandler.
    If I use the way of Qt5 to connect signals
    @QObject::connect(&codeGenerator, &CodeGenerator::error, &errHandler, &ErrorHandler::error);
    QObject::connect(&codeGenerator, &CodeGenerator::warning, &errHandler, &ErrorHandler::warning);@
    I get "too many initializers" error:
    @D:\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtCore/qobject_impl.h(82) : error C2078: too many initializers
    D:\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtCore/qobject_impl.h(81) : while compiling class template member function 'const int *QtPrivate::ConnectionTypes<ArgList>::types(void)'
    ArgList=QtPrivate::List<int,QtPrivate::List<QString,QtPrivate::List<int,QtPrivate::List<QFile *,void>>>>
    d:\qt\qt5.0.0\5.0.0\msvc2010\include\qtcore\qobject.h(245) : see reference to class template instantiation 'QtPrivate::ConnectionTypes<ArgList>' being compiled
    ArgList=QtPrivate::List<int,QtPrivate::List<QString,QtPrivate::List<int,QtPrivate::List<QFile ,void>>>>
    ..\Compiler\main.cpp(54) : see reference to function template instantiation 'QMetaObject::Connection QObject::connect<void(__thiscall CodeGenerator::
    )(int,QString,int,QFile ),void(__thiscall ErrorHandler:: )(int,QString,int,QFile *)>(const CodeGenerator *,Func1,const ErrorHandler ,Func2,Qt::ConnectionType)' being compiled
    Func1=void (__thiscall CodeGenerator::
    )(int,QString,int,QFile ),
    Func2=void (__thiscall ErrorHandler::
    )(int,QString,int,QFile *)

    What did I miss?

    Thank you for your answers.

  • Moderators

    I don't see anything wrong in this code. I would suggest filing a bug report, but it would be nice to get a second voice on this beforehand.

Log in to reply