qt项目中未解析的外部符号
Unresolved external symbol in qt project
好的,所以花 30 分钟左右的时间查看此问题的常见原因,我看不出出了什么问题。
我得到的错误是未解析的外部符号。有问题的符号是一个名为AdventureDocs的类。标题如下。
#ifndef ADVENTUREDOCS_H
#define ADVENTUREDOCS_H
#include <QWidget>
class AdventureDocs : public QWidget
{
Q_OBJECT
public:
AdventureDocs(QObject *parent);
};
#endif // ADVENTUREDOCS_H
和菲共
#include "adventuredocs.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QTabWidget>
AdventureDocs::AdventureDocs(QObject *parent): QWidget(parent)
{
QHBoxLayout *hLayout = 0;
QVBoxLayout *vLayout = 0;
QPushButton *button = 0;
QLabel *label = 0;
hLayout = new QHBoxLayout();
Q_ASSERT(hLayout);
vLayout = new QVBoxLayout();
Q_ASSERT(vLayout);
// Set the layout to the widget
setLayout(hLayout);
hLayout->addLayout(vLayout);
// Draw widgets on main page.
label = new QLabel(hLayout);
Q_ASSERT(label);
hLayout->addWidget(label);
label->setText("Adventure Docs");
}
这是一个类,而不是库或任何聪明的东西,我使用在qt creator中添加新类来添加它,并将标头和cpp添加到项目文件中,如下所示。
#-------------------------------------------------
#
# Project created by QtCreator 2016-06-12T11:06:47
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = AdventureDocs
TEMPLATE = app
SOURCES += main.cpp
mainwindow.cpp
adventuredocs.cpp
HEADERS += mainwindow.h
adventuredocs.h
FORMS += mainwindow.ui
最后,在主.cpp窗口中,我创建AdventureDocs对象的地方是我收到错误的地方。
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include "adventuredocs.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
AdventureDocs *main = 0;
main = new AdventureDocs(this);
if (main != 0)
{
setCentralWidget(main);
}
}
MainWindow::~MainWindow()
{
delete ui;
}
有人可以指出我显然错过的出血明显,谢谢。
现在解决了。 我是不是很傻,没有重新运行Qmake。
相关文章:
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 未解析的外部符号_MsiLocateComponentW@12.
- 在C++中使用 gRPC 时未解析的外部符号
- LibPrivoxy: 未解析的外部符号 __declspec(dllimport) int __stdcall Sta
- 尝试从 XamlApplication 编译 C++/WinRT 空白应用程序时,我收到未解析的外部符号 winrt_make_*
- 我收到错误LNK2001:未解析的外部符号(C++代码)
- 可视抽象类 c++(错误 LNK 2001:未解析的外部符号)
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 仅在少数方法(静态或共享库)中解析的外部符号
- 未解析的外部符号"__declspec(dllimport)与 Spdlog c++ 库
- 函数 _main (OPENGL C++) 中引用的未解析的外部符号 ________
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 使用静态 constexpr 成员的未解析外部符号
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- Dlib LNK2001未解析的外部符号USER_ERROR__consistent_build_configurati
- 矛盾的未解决的外部符号+未使用的库与VS2017和FFMPEG 4
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- 类模板上一个特定函数的未解析外部符号
- LNK2001:未解析的外部符号public:static类std::vector