简体   繁体   English

QT创建者链接错误1120

[英]QT Creator Linking Error 1120

I have been trying to compile my project in Qt Creator. 我一直试图在Qt Creator中编译我的项目。 I have run qmake and clean multiple times but I am still encountering a linking error. 我已经运行过qmake并清理了多次,但是仍然遇到链接错误。

moc_test.obj:-1: error: LNK2019: unresolved external symbol "private: void __cdecl Test::on_cboxMode_activated(class QString const &)" (?on_cboxMode_activated@Test@@AEAAXAEBVQString@@@Z) referenced in function "private: static void __cdecl Test::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall`enter code here`@Test@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)

This is the project file 这是项目文件

#-------------------------------------------------
#
# Project created by QtCreator 2013-10-25T13:51:21
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Test
TEMPLATE = app


SOURCES += test.cpp\
            main.cpp


HEADERS  += test.h

FORMS    += test.ui

This is my cpp file 这是我的cpp文件

#include "test.h"
#include "ui_test.h"
#include <QFileDialog>

Test::Test(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Test)
{
    ui->setupUi(this);
}

Test::~Test()
{
    delete ui;
}

//********************************//
//**Browse and Select A Fit File**//
//********************************//
void Test::on_btnFitBrowse_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(this,tr("Open File"), "/home/", tr("Comma Delimited (*.csv);;Text Files (*.txt);;All Files(*)"));
    ui->txtFitEdit->setText(fileName);
}

//*********************************//
//**Browse and Select A Test File**//
//*********************************//
void Test::on_btnTestBrowse_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(this,tr("Open File"), "/home/", tr("Comma Delimited (*.csv);;Text Files (*.txt);;All Files(*)"));
    ui->txtTestEdit->setText(fileName);
}

//--------------------------------------------------------------------//
//----------------------------Model Window----------------------------//
//--------------------------------------------------------------------//

//***************//
//**Select Mode**//
//***************//
void Test::on_cboxMode_activated(int index)
{
    //Auto Mode
    if(index==0)
    {
        ui->rdoBestTMinMSE->setEnabled(false);
        ui->rdoBestTMaxF->setEnabled(false);
    }
    //Manual Mode
    else if(index==1)
    {
        ui->rdoBestTMinMSE->setEnabled(true);
        ui->rdoBestTMaxF->setEnabled(true);
    }
}

This is my header file 这是我的头文件

#ifndef TEST_H
#define TEST_H

#include <QMainWindow>
#include <QRadioButton>

namespace Ui {
class Test;
}

class Test : public QMainWindow
{
    Q_OBJECT

public:
    explicit Test(QWidget *parent = 0);
    ~Test();

private slots:
    void on_btnFitBrowse_clicked();

    void on_btnTestBrowse_clicked();

    void on_cboxMode_activated(const QString &arg1);

    void on_cboxMode_activated(int index);

private:
    Ui::Test *ui;
};

#endif // TEST_H

My directory structure looks like this 我的目录结构如下所示

+---Test Qt
¦   +---build-Test-Desktop_Qt_5_1_1_MSVC2012_OpenGL_64bit-Debug
¦   ¦   +---debug
¦   ¦   +---release
¦   +---build-Test-Desktop_Qt_5_1_1_MSVC2012_OpenGL_64bit-Release
¦   ¦   +---debug
¦   ¦   +---release
¦   +---Test

Most likely you have a Test::on_cboxMode_activated that takes a QString& into the test.h and in the test.cpp you have the method with an int parameter. 很可能您有一个Test :: on_cboxMode_activated,它将QString&放入test.h中,而在test.cpp中,您具有带有int参数的方法。 //if that is not the case please post the code from test.h too //如果不是这种情况,请也从test.h发布代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM