Errors for dialog.obj



  • Hi Guys,

    I will be appriciate if someone could give me some suggestions regarding some errors I got.

    environment: Qt5.2.1 + MS Visual Studio 2010.
    Since I'm a new fish for Qt development, and I try to program a small application to evaluate my environment setup. Followings are codes:

    dialog.h
    @#pragma once

    #ifndef DIALOG_H
    #define DIALOG_H

    #include <QtWidgets\qdialog.h>

    namespace Ui {
    class Dialog;
    }

    class Dialog : public QDialog
    {
    Q_OBJECT

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

    private slots:
    void on_countBtn_clicked();

    void on_radiusLineEdit_textChanged(const QString &arg1);
    

    private:
    Ui::Dialog *ui;
    };

    #endif // DIALOG_H@

    ui-dialog.h
    @#pragma once
    /********************************************************************************
    ** Form generated from reading UI file 'dialog.ui'
    **
    ** Created by: Qt User Interface Compiler version 5.0.2
    **
    ** WARNING! All changes made in this file will be lost when recompiling UI file!
    ********************************************************************************/

    #ifndef UI_DIALOG_H
    #define UI_DIALOG_H

    #include <QtCore/QVariant>
    #include <QtWidgets/QAction>
    #include <QtWidgets/QApplication>
    #include <QtWidgets/QButtonGroup>
    #include <QtWidgets/QDialog>
    #include <QtWidgets/QHeaderView>
    #include <QtWidgets/QLabel>
    #include <QtWidgets/QLineEdit>
    #include <QtWidgets/QPushButton>

    QT_BEGIN_NAMESPACE

    class Ui_Dialog
    {
    public:
    QLabel *radiusLabel;
    QLabel *areaLabel_1;
    QLabel *areaLabel_2;
    QLineEdit *radiusLineEdit;
    QPushButton *countBtn;

    void setupUi(QDialog *Dialog)
    {
        if (Dialog->objectName().isEmpty())
            Dialog->setObjectName(QStringLiteral("Dialog"));
        Dialog->resize(333, 129);
        radiusLabel = new QLabel(Dialog);
        radiusLabel->setObjectName(QStringLiteral("radiusLabel"));
        radiusLabel->setGeometry(QRect(20, 40, 41, 21));
        areaLabel_1 = new QLabel(Dialog);
        areaLabel_1->setObjectName(QStringLiteral("areaLabel_1"));
        areaLabel_1->setGeometry(QRect(160, 40, 31, 21));
        areaLabel_2 = new QLabel(Dialog);
        areaLabel_2->setObjectName(QStringLiteral("areaLabel_2"));
        areaLabel_2->setGeometry(QRect(200, 40, 101, 21));
        areaLabel_2->setFrameShape(QFrame::Panel);
        areaLabel_2->setFrameShadow(QFrame::Sunken);
        radiusLineEdit = new QLineEdit(Dialog);
        radiusLineEdit->setObjectName(QStringLiteral("radiusLineEdit"));
        radiusLineEdit->setGeometry(QRect(60, 40, 81, 20));
        countBtn = new QPushButton(Dialog);
        countBtn->setObjectName(QStringLiteral("countBtn"));
        countBtn->setGeometry(QRect(230, 80, 75, 23));
    
        retranslateUi(Dialog);
    
        QMetaObject::connectSlotsByName(Dialog);
    } // setupUi
    
    void retranslateUi(QDialog *Dialog)
    {
        Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0));
        radiusLabel->setText(QApplication::translate("Dialog", "\345\215\212\345\276\204\357\274\232", 0));
        areaLabel_1->setText(QApplication::translate("Dialog", "\351\235\242\347\247\257\357\274\232", 0));
        areaLabel_2->setText(QString());
        countBtn->setText(QApplication::translate("Dialog", "\350\256\241\347\256\227", 0));
    } // retranslateUi
    

    };

    namespace Ui {
    class Dialog: public Ui_Dialog {};
    } // namespace Ui

    QT_END_NAMESPACE

    #endif // UI_DIALOG_H
    @

    dialog.cpp
    @#include "dialog.h"
    #include "ui_dialog.h"

    const static double PI=3.1416;

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

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

    void Dialog::on_countBtn_clicked()
    {
    bool ok;
    QString tempStr;
    QString valueStr=ui->radiusLineEdit->text();
    int valueInt=valueStr.toInt(&ok);
    double area=valueIntvalueIntPI;//
    ui->areaLabel_2->setText(tempStr.setNum(area));
    }

    void Dialog::on_radiusLineEdit_textChanged(const QString &arg1)
    {
    bool ok;
    QString tempStr;
    QString valueStr=ui->radiusLineEdit->text();
    int valueInt=valueStr.toInt(&ok);
    double area=valueIntvalueIntPI;//
    ui->areaLabel_2->setText(tempStr.setNum(area));
    }@

    main.cpp
    @#include "dialog.h"
    #include <QtWidgets/qapplication.h>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    Dialog w;
    w.show();

    return a.exec&#40;&#41;;
    

    }@

    All necessary libraries and included files are added in the project common properties.

    When I tried to compile the previous codes, there are always some errors appears:

    Error 1 error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Dialog::metaObject(void)const " (?metaObject@Dialog@@UBEPBUQMetaObject@@XZ) G:\MyProject\OpenCV\Qt\dialog.obj Qt

    Error 2 error LNK2001: unresolved external symbol "public: virtual void * __thiscall Dialog::qt_metacast(char const *)" (?qt_metacast@Dialog@@UAEPAXPBD@Z) G:\MyProject\OpenCV\Qt\dialog.obj Qt

    Error 3 error LNK2001: unresolved external symbol "public: virtual int __thiscall Dialog::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Dialog@@UAEHW4Call@QMetaObject@@HPAPAX@Z) G:\MyProject\OpenCV\Qt\dialog.obj Qt

    Error 4 error LNK1120: 3 unresolved externals G:\MyProject\OpenCV\Debug\Qt.exe 1 1 Qt

    Can some one tell me how to solve this problem? Thank you in advance!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.