【发布时间】:2018-10-01 09:15:31
【问题描述】:
我有一个像这样设置的 qt 项目
标题
mainwindow.h
来源
main.cpp
mainwindow.cpp
在 mainwindow.h 中
just some function prototypes no includes
在 mainwindow.cpp 中
#include "mainwindow.h"
some code
在main.cpp中
#include "mainwindow.h"
这似乎可行,这就是 qt IDE 设置程序的方式
现在我想为某些功能添加单独的 .h 和 .cpp 程序
动画函数.h
#ifndef ANIMATIONFUNCTIONS_H
#define ANIMATIONFUNCTIONS_H
QPropertyAnimation* animationbuttonleft(QPushButton* guiitem, QString location, int startposition);
#endif // ANIMATIONFUNCTIONS_H
动画函数.cpp
#include "animationfunctions.h"
QPropertyAnimation* animationbuttonleft(QPushButton* guiitem, QString location, int startposition)
{
//
}
主窗口.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "animationfunctions.h"
我认为这会起作用,但它没有。我尝试了很多不同的包含组合,但我总是得到一个 lnk 2019 错误,QPropertyAnimation* animationbuttonleft 的外部符号未解析
我想知道我应该如何设置它?
这是我的 .pro 文件的相关部分
SOURCES += \
main.cpp \
mainwindow.cpp \
animationfunctions.cpp
HEADERS += \
mainwindow.h \
xcash_wallet_2.rc \
animationfunctions.h
谢谢
【问题讨论】:
-
对不起。 .pro文件中
SOURCES +=或HEADERS +=后面的代码,为什么不在一行?
标签: c++ qt linker-errors unresolved-external