• 6268阅读
  • 4回复

[原创]求助Qt中使用QML问题 [复制链接]

上一主题 下一主题
离线xiaowenlg
 
只看楼主 倒序阅读 楼主  发表于: 2012-05-12
我的环境是VS2008+QT
代码如下

#include <QtGui/QApplication>
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativecontext.h>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDeclarativeView view;
//view.rootContext()->setContextProperty("stopwatch", new Stopwatch);

return a.exec();
}
代码编译出错
1>main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual __thiscall QDeclarativeView::~QDeclarativeView(void)" (__imp_??1QDeclarativeView@@UAE@XZ),该符号在函数 _main 中被引用
1>main.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall QDeclarativeView::QDeclarativeView(class QWidget *)" (__imp_??0QDeclarativeView@@QAE@PAVQWidget@@@Z),该符号在函数 _main 中被引用
1>D:\VC_prj\QML_Play\Debug\QML_Play.exe : fatal error LNK1120: 2 个无法解析的外部命令



请大家帮忙看看怎么回事啊
我是一个QT的初学者,请详细告知,在此谢过!
离线XChinux

只看该作者 1楼 发表于: 2012-05-13
在.pro中加
QT+=declarative
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线xiaowenlg
只看该作者 2楼 发表于: 2012-05-13
加了QT+=declarative

。pro文件

# ----------------------------------------------------
# This file is generated by the Qt Visual Studio Add-in.
# ------------------------------------------------------
# This is a reminder that you are using a generated .pro file.
# Remove it when you are finished editing this file.
message("You are running qmake on a generated .pro file. This may not work!")

TEMPLATE = app
TARGET = QML_Play
DESTDIR = ../Debug
QT += core gui multimedia sql network xml script xmlpatterns qtmain webkit opengl
CONFIG += qtestlib debug
DEFINES += QT_LARGEFILE_SUPPORT QT_XML_LIB QT_SQL_LIB QT_OPENGL_LIB QT_NETWORK_LIB QT_SCRIPT_LIB QT_WEBKIT_LIB QT_MULTIMEDIA_LIB QT_XMLPATTERNS_LIB
INCLUDEPATH += ./GeneratedFiles \
    ./GeneratedFiles/Debug \
    .
LIBS += -lopengl32 \
    -lglu32
DEPENDPATH += .
MOC_DIR += ./GeneratedFiles/debug
OBJECTS_DIR += debug
UI_DIR += ./GeneratedFiles
RCC_DIR += ./GeneratedFiles
include(QML_Play.pri)
QT+=declarative
离线xiaowenlg
只看该作者 3楼 发表于: 2012-05-13
回 2楼(xiaowenlg) 的帖子
加了还是不行呢
离线xuweistudy
只看该作者 4楼 发表于: 2012-05-13
回 3楼(xiaowenlg) 的帖子
试试重新生成工程,qmake
快速回复
限100 字节
 
上一个 下一个