【发布时间】:2018-06-25 07:18:40
【问题描述】:
我基于Qt5.10.0安装了Qt Creator 4.5.0,做了一个简单的项目。
#include "widget.h"
#include <QApplication>
#include <QTextEdit>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTextEdit textEdit;
textEdit.show();
return a.exec();
}
我构建了这个项目并收到了这条消息。
ld: library not found for -lQt5Widgets_debug
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我使用 macOS10.13.2、Xcode9.2。我该怎么办? 我必须为此安装一些库吗?
.pro 在下面。
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Test1
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
widget.cpp
HEADERS += \
widget.h
FORMS += \
widget.ui
widget.h 在下面。
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
widget.cpp 在下面。
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
感谢您观看此视频。
【问题讨论】:
-
展示你的 .pro.
-
感谢您观看这个问题。我在上面添加了.pro。
-
在 main.cpp 中你包括
#include "widget.h"... 什么是 widget.h ?? -
我添加了 widget.h 和 widget.cpp。请观看。
-
你是如何安装 Qt5 的?