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

Unresolved external symbol errors in basic project



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

    On a very basic app. I created an Editor class using the C++ header / source convention and am getting weird errors like this. No cyclically included headers.

    Is this a no brainer or do you need more info from me?

    I am getting these even though I write out the functions in the header file and remove the editor.cpp from the project. IT'S WEIRD.


  • Lifetime Qt Champion

    Hi,

    Did you properly export/import the class ?

    Can you show the header you wrote ?



  • This post is deleted!


  • This post is deleted!


  • @SGaist Still getting the error. Here is my editor.h:

    #ifndef EDITOR_H
    #define EDITOR_H
    
    #include <QMainWindow>
    #include <QGraphicsView>
    
    class Editor : public QGraphicsView
    {
    public:
        Editor(QString& name, QMainWindow* window);
        QString& tabName();
    
    private:
        QMainWindow* m_window;
        QString m_name;
    };
    
    #endif // EDITOR_H
    

    And my editor.cpp:

    #include "editor.h"
    
    Editor::Editor(QString& name, QMainWindow* window)
    {
        m_name = name;
        m_window = window;
    }
    
    QString& Editor::tabName() {
        return m_name;
    }
    


  • Okay I fixed it by just creating a Qt Form Class with the new item wizard and renaming everything with QWidget to QGraphicsView, etc


  • Lifetime Qt Champion

    Can you show your new version of your code ?


Log in to reply