A problem about "undefined reference to `Clean::Clean(QObject*)'
Hello experts.
This is my project. It's a Symbian project:
.PRO:
Code:
folder_01.source = qml/GCleaner
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01
symbian:TARGET.CAPABILITY += NetworkServices
CONFIG += qt
CONFIG += qt-components
SOURCES += main.cpp
QT += declarative
files.sources += main.qml
DEPLOYMENT += files
include(qmlapplicationviewer/qmlapplicationviewer.pri)
qtcAddDeployment()
CPP:
Code:
#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include <QObject>
#include <QApplication>
#include <QDeclarativeView>
#include <QDeclarativeContext>
#include <QDir>
#include <QFile>
void deleteDir(const std::string& foldername)
{
dir.rmdir(foldername.c_str());
}
Q_OBJECT
public:
Q_INVOKABLE void delete() {
deleteDir(c:/temp)
};
int main(int argc, char *argv[])
{
Clean clean;
QDeclarativeView view;
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
view.rootContext()->setContextProperty("Clean", &clean);
view.
setSource(QUrl("./main.qml"));
return app.exec();
}
QML:
Code:
import QtQuick 1.1
import com.nokia.symbian 1.1
Window {
id: window
Button {
id:button
onClicked: Clean.delete
} }
It tells me that "undefined reference to `Clean::Clean(QObject*)' " and "undefined reference for `vtable for Clean'
I'm building this app for Symbian and I'm stuck at that. Please help me out.
My best regards,
George Dao.
Re: A problem about "undefined reference to `Clean::Clean(QObject*)'
In Clean constructor defined?
Also it's a very good practice to write QObject derived classes in it's own header and cpp, else you need to include the .moc generated file for your QObjec derived class.
Re: A problem about "undefined reference to `Clean::Clean(QObject*)'
Thanks for your help. It's highly appreciated.
Sorry but my English is poor, and I'm so new to Qt. In my country there's no centre teaching Qt, so I have to learn it myself. You can call me "a noob". This is also my first Qt project ever made.
I believe Clean constructor is defined. I did everything similar to this sample project from Nokia Dev page:
But it doesn't work.
By the way, the problem is at .CPP file, line 30.
Could you please help me more? Thank you so much for that.
My best regards,
George Dao.
Re: A problem about "undefined reference to `Clean::Clean(QObject*)'
Quote:
Originally Posted by
GeorgeDao123
I believe Clean constructor is defined.
If you didn't define it in a separate file that you didn't post here then I believe the constructor is not defined, only declared. And based on the project file that you posted I believe main.cpp is your only C++ file (apart qmlapplicationviewer) thus I believe there are no other files in your project where you might have defined the constructor. This is basic C++ stuff, nothing Qt related.
Re: A problem about "undefined reference to `Clean::Clean(QObject*)'
Quote:
Originally Posted by
wysota
If you didn't define it in a separate file that you didn't post here then I believe the constructor is not defined, only declared. And based on the project file that you posted I believe main.cpp is your only C++ file (apart qmlapplicationviewer) thus I believe there are no other files in your project where you might have defined the constructor. This is basic C++ stuff, nothing Qt related.
Thank you so much for your help. I'll follow your instruction.