Please nominate your Qt Champions for 2021!

Error Due to automatic update of moc_application.cpp file

  • Dear Developer,

    Please help me solve following error.

    In my application first by mistake I have added slot "cursorPositionChanged" for Line Edit widget. Corresponding to which I get

    1. on_LineEdit_cursorPositionChanged() slot in my application.cpp file

    2. case 31: _t->on_stepLineEdit_cursorPositionChanged((reinterpret_cast< int()>(_a[1])),(reinterpret_cast< int()>(_a[2]))); break;

    entry in my moc_application.cpp file.

    Later, after realizing my mistake when I have deleted above given code and rebuild my application I get following error.

    error: undefined reference to `Application::on_LineEdit_cursorPositionChanged(int, int)' in moc_application.cpp file

    Please inform me from where code:

    case 31: _t->on_stepLineEdit_cursorPositionChanged((reinterpret_cast< int()>(_a[1])),(reinterpret_cast< int()>(_a[2]))); break;

    appear in my moc_application.cpp file after I do "Clean all" and "Rebuild all" , even after I have deleted it from moc_application.cpp file before rebuilding my application.

    Kindly inform me if you need any information from me.

    Thank you very much :)

  • Moderators

    Try removing the whole build directory and building again. Also, run qmake manually in Qt Creator (right click on your project and select "Run qmake"), then build.

    I have deleted above given code

    So you have removed the slot from both application.h and application.cpp?

  • Hello Sierdzio,

    Thank you very much for your reply actually I forget to remove slot from application.h file.

    After I deleted declaration of slot from .h file everything went fine.

    Thank you :)

  • Moderators

    You're welcome. Happy coding :-)

Log in to reply