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

Unresolved external symbol calling some simple constructive code inside of a slot generated by designer.



  • void MainWindow::on_actionNew_triggered()
    {
        auto tab_name = QString("New_blank");
        auto editor = new Editor(tab_name);
        addEditor(editor);
    }
    

    Thats the slot, the protototype was generated by "go to slot" from designer.

    However it always results in:

    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl Editor::Editor(class QString &)" (??0Editor@@QEAA@AEAVQString@@@Z) referenced in function "private: void __cdecl MainWindow::on_actionNew_triggered(void)" (?on_actionNew_triggered@MainWindow@@AEAAXXZ)
    

    Which makes no sense to me at all because I'm that new. So what do I need to indicate in order to actually do something in the slot?


    Things I've tried:

    • Wrapping the code in a void function in MainWindow. Now the call to that is unresolved... seems I can't do anything in the slot.
    • Switching to release - it builds. But I need to debug!
    • Changing the order of the source files in the .pro make file. no difference.

    It says in red next to the error "File not found: mainwindow.obj" but I checked in the debug directory and they're there. editor.obj is not there however, it is in the .pro makefile, so Idk what's going on...


  • Lifetime Qt Champion

    Hi
    It says
    I cannot find
    public: __cdecl Editor::Editor(class QString &)

    where u use it in on_actionNew_triggered

    so is the constructor like that ?
    in your other post it was
    Editor(QString& name, QMainWindow* window);

    so it should be like
    auto editor = new Editor(tab_name, this);

    if its still like that.




  • Lifetime Qt Champion

    @enjoysmath
    Try Clean and then Rebuild all.


  • Lifetime Qt Champion

    Hi,

    Silly question but did you implement that constructor ?


Log in to reply