我刚做brew install qt5
qmake
有效,但Makefile没有,给我一个致命错误" QtWidgets not found"我从教程中复制和粘贴的。
我理解这是与框架的链接问题,但我尝试过这样的事情并不奏效:
QMAKE_LFLAGS += -F/usr/local/Cellar/qt5/5.6.1-1/lib
LIBS += -framework QtWidgets.framework
任何方式正确链接?代码是:
#include <QtWidgets>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(320, 240);
window.show();
window.setWindowTitle(
QApplication::translate("toplevel", "Top-level widget"));
return app.exec();
}
.pro文件是:
SOURCES = main.cpp
QMAKE_LFLAGS += -F/usr/local/Cellar/qt5/5.6.1-1/lib
LIBS += -framework QtWidgets.framework
# install
target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/toplevel
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS toplevel.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/toplevel
INSTALLS += target sources
symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
symbian: warning(This example might not fully work on Symbian platform)
maemo5: warning(This example might not fully work on Maemo platform)
simulator: warning(This example might not fully work on Simulator platform)
我从官方网站上检索了这两个。