QT Creator - LNK2019 error when editing the MainWindow.cpp constructor code
-
Added an InitMain function to a brand new QT Widget -> QT Gui Application so that my code calls the InitMain in the MainWindow's constructor. When compiling I get this error:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall MainWindow::InitMain(void)" (?InitMain@MainWindow@@QAEXXZ) referenced in function "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z)
Any help on resolving this issue would be much appreciated
-
Yes. Here's the .h and .cpp files for MainWindow (everything's default per the project creator other than the InitMain() function stuff)
@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);
void InitMain();
~MainWindow();private:
Ui::MainWindow *ui;
};#endif // MAINWINDOW_H
@@
#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
InitMain();
}MainWindow::~MainWindow()
{
delete ui;
}void InitMain()
{
int i = 5;
i++;
}
@(I do realize that at this time InitMain is a pointless function)
-
Please tag your code with '@' as explained "here ":http://developer.qt.nokia.com/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01
-
My appologies on not using the 'at' symbol. Thanks also for the solution. Checking it now. I'm not yet used to using the class definition before methods/functions