login.obj:-1:错误:LNK2019:未解析的外部符号

时间:2016-10-11 21:59:33

标签: c++ qt lnk2019 unresolved-external

login.h:

#ifndef LOGIN_H
#define LOGIN_H

#include <QMainWindow>
#include "usecase.h"
#include <QtSql>
#include <QDebug>
#include <QFileinfo>


namespace Ui {
class login;
}

class login : public QMainWindow
{
    Q_OBJECT

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

private slots:
    void on_pushButton_clicked();

    void on_e_clicked();

    void on_pushButton_2_clicked();

private:
    Ui::login *ui;
    QSqlDatabase db;

    usecase *uc;

};

#endif // LOGIN_H

login.cpp

#include "login.h"
#include "ui_login.h"

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

    db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabaseName("C:/sqlite/lms2.sqlite");
        if(!db.open())
            {
                ui->log->setText("Failure! Database Unavailable");
            }
            else
            {
               ui->log->setText("Database connected. You may log in");
            }
}

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

void login::on_pushButton_clicked()
{
    QString usr,pass;
        usr = ui->lineEdit->text();
        pass = ui->lineEdit_2->text();
        QString u_c;


        QSqlQuery sq;

        sq.exec("select * from user where username  = '"+usr+"' and password = '"+pass+"'");
        if(sq.next())
        {
            ui->con->setText("Logged in successfully");
            u_c = sq.value(5).toString();
            u_c.toStdString();
            if(u_c == "a")
            {
                qDebug()<<"a";
                uc = new usecase(this);
                uc->show();

            }
            if(u_c == "c")
            {
                qDebug()<<"c";
               // uc = new usecase(this);
                //uc->show();
            }
            if(u_c == "s")
            {
                qDebug()<<"s";
              //  uc = new usecase(this);
               // uc->show();
            }
        }
        else
        {
            ui->con->setText("Login Failure");
        }
}

void login::on_e_clicked()
{
    QCoreApplication::exit();
}

void login::on_pushButton_2_clicked()
{
    ui->lineEdit->setText("");
    ui->lineEdit_2->setText("");
}

usecase.h:

#ifndef USECASE_H
#define USECASE_H

#include <QDialog>
#include "view_info.h"

namespace Ui {
class usecase;
}

class usecase : public QDialog
{
    Q_OBJECT

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

private slots:
    void on_viewinfo_clicked();

private:
    Ui::usecase *ui;
    view_info *vi;
};

#endif // USECASE_H

usecase.cpp:

#include "usecase.h"
#include "ui_usecase.h"

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

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

void usecase::on_viewinfo_clicked()
{
  //  vi = new view_info(this);
   // vi->show();

}

view_info.h:

#ifndef VIEW_INFO_H
#define VIEW_INFO_H

#include <QDialog>

#include <QtSql>
#include <QDebug>
#include <QFileinfo>

namespace Ui {
class view_info;
}

class view_info : public QDialog
{
    Q_OBJECT

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

private slots:
    void on_pushButton_clicked();

private:
    Ui::view_info *ui;
};

#endif // VIEW_INFO_H

view_info.cpp:

#include "view_info.h"
#include "ui_view_info.h"

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

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

void view_info::on_pushButton_clicked()
{
    QString rn = ui->lineEdit->text();

    QSqlQuery sq;

    ui->info_rnum->setText(rn);
        sq.exec("select * from user where Roll Number  = '"+rn+"'");
        if(sq.next())
        {
            ui->lineEdit_2->setText(sq.value(0).toString());
            ui->lineEdit_3->setText(sq.value(1).toString());
            ui->lineEdit_4->setText(sq.value(2).toString());
            ui->lineEdit_5->setText(sq.value(3).toString());

        }
}

当我尝试做&#34; uc = new usecase(this);&#34;我得到了上述错误。我还尝试使用setmodal()打开新表单。但这也给了一个错误。如果你能找到什么错误请告诉你。

错误是:

login.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall usecase::usecase(class QWidget *)" (??0usecase@@QAE@PAVQWidget@@@Z) referenced in function "private: void __thiscall login::on_pushButton_clicked(void)" (?on_pushButton_clicked@login@@AAEXXZ)

0 个答案:

没有答案