Just a test project with one class (nothing in it) and one qml file and a main.cpp – my purpose is to learn how to take a c++ variable value and display it via qml.
Class just has a constructor, nothing else. The project compiles and links until main.cpp creates an instance of my class at which point it tries to find the class.obj file and it is not there. Main.cpp and class.cpp are in the same directory. Shadow build has been disabled. I have tried clean and rebuild, I have even tried deleting the debug output directory manually. Class.h/cpp are in the project file.
I have created this project twice from scratch and got the same thing: – create the project, it runs and displays the qml – add a new class to project, still runs – add one line into main.cpp creating an instance of class -> link error (cannot find the constructor – which is not surprising if the obj is not there)
Any ideas at all?
main.cpp
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQuickView *viewer = new QQuickView();
CGuideMenu *cMenu = new CGuideMenu(viewer);
viewer->setSource(QUrl::fromLocalFile("main.qml"));
viewer->show();
return app.exec();
}
class header
class CGuideMenu
{
public:
CGuideMenu(QObject *parent);
};
class cpp
CGuideMenu::CGuideMenu(QObject *parent)
{
}
.pro
# Add more folders to ship with the application, here
folder_01.source = qml/GuideNext
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01
# Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH =
# If your application uses the Qt Mobility libraries, uncomment the following
# lines and add the respective components to the MOBILITY variable.
# CONFIG += mobility
# MOBILITY +=
# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp \
guidemenu.cpp
# Please do not modify the following two lines. Required for deployment.
include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
qtcAddDeployment()
HEADERS += \
guidemenu.h
↧