找不到文件:mainwindow.obj [英] File not found: mainwindow.obj

查看:78
本文介绍了找不到文件:mainwindow.obj的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我创建了一个GUI应用程序-> QMainWindow
  2. 我在菜单+插槽中添加了1个项目.
  3. 我创建了一个新项目-> QDialog
  4. 我尝试显示创建的对话框的slot方法,但出现此错误:

  1. I created a GUI Application -> QMainWindow
  2. I added 1 item to the menu + the slot.
  3. I created a new item -> QDialog
  4. I the slot method i try to show the created dialog but i get this errors:

mainwindow.obj:-1:错误:LNK2019:未解决的外部符号公共:__ cdecl EditStudentDialog :: EditStudentDialog(class QWidget *)"(?? 0EditStudentDialog @@ QEAA @ PEAVQWidget @@@@ Z):void __cdecl MainWindow :: on_actionNew_triggered(void)(?on_actionNew_triggered @ MainWindow @@ AEAAXXZ)

mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl EditStudentDialog::EditStudentDialog(class QWidget *)" (??0EditStudentDialog@@QEAA@PEAVQWidget@@@Z) referenced in function "private: void __cdecl MainWindow::on_actionNew_triggered(void)" (?on_actionNew_triggered@MainWindow@@AEAAXXZ)

mainwindow.obj:-1:错误:LNK2019:无法解析的外部符号公共:虚拟__cdecl EditStudentDialog ::〜EditStudentDialog(void)"(?? 1EditStudentDialog @@ UEAA @ XZ)在函数私有:void __cdecl MainWindow中引用":: on_actionNew_triggered(void)"(?on_actionNew_triggered @ MainWindow @@ AEAAXXZ)

mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: virtual __cdecl EditStudentDialog::~EditStudentDialog(void)" (??1EditStudentDialog@@UEAA@XZ) referenced in function "private: void __cdecl MainWindow::on_actionNew_triggered(void)" (?on_actionNew_triggered@MainWindow@@AEAAXXZ)

这是主窗口:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

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

private slots:
    void on_actionNew_triggered();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "editstudentdialog.h"

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

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

void MainWindow::on_actionNew_triggered()
{
    EditStudentDialog editDialog;
    editDialog.setModal(true);
    editDialog.exec();
}

这是对话框(只是一个空对话框,没有任何控件):

This is the dialog ( just an empty one, no controls on it ):

#ifndef EDITSTUDENTDIALOG_H
#define EDITSTUDENTDIALOG_H

#include <QDialog>

namespace Ui {
class EditStudentDialog;
}

class EditStudentDialog : public QDialog
{
    Q_OBJECT

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

private:
    Ui::EditStudentDialog *ui;
};

#endif // EDITSTUDENTDIALOG_H


#include "editstudentdialog.h"
#include "ui_editstudentdialog.h"

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

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

我在做什么错了?

这是.pro文件

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = GUI1
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    editstudentdialog.cpp

HEADERS  += mainwindow.h \
    editstudentdialog.h

FORMS    += mainwindow.ui \
    editstudentdialog.ui

PS:我试图清理项目,然后构建它,但仍然是同样的问题.

PS: I tried to clean the project and then build it but still the same issue.

我在Qt 5.0.2中使用Qt Creator 2.7

EDIT 2: I am using Qt Creator 2.7 with Qt 5.0.2

推荐答案

似乎editstudentdialog.obj文件未正确创建.尝试清理项目(构建"->全部清除"),然后再次构建.如果这样做没有帮助,请检查是否将editstudentdialog.cpp添加到.pro文件中的SOURCES变量中.如果仍然没有反应,请提供.pro文件.

It seems that editstudentdialog.obj file is not created properly. Try to clean the project (Build->Clean all) and the build it again. If it does not help check if editstudentdialog.cpp is added to the SOURCES variable in your .pro file. If still nothing happens please provide the .pro file.

如下所述,您也可以尝试删除整个应用,然后重新创建.

As was mentioned below, you may also try to delete the whole app and create it again.

这篇关于找不到文件:mainwindow.obj的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆