error: ‘QVariant::QVariant(void*)’ is private within this context
Hello,
Does someone would know what could be the problem ?
error: ‘QVariant::QVariant(void*)’ is private within this context
I'm trying simply to expose the class Tool to the QML file like that:
Code:
QDeclarativeView *view = new QDeclarativeView();
view->rootContext()->setContextProperty("Tool", new Tool);
view
->setSource
(QUrl("qrc:/qml/main.qml"));
view->show();
Any help would be appreciated
Cheers !
Re: error: ‘QVariant::QVariant(void*)’ is private within this context
How is 'Tool' defined?
On which line of the given code is the compile error you get?
Re: error: ‘QVariant::QVariant(void*)’ is private within this context
Tool class definition:
Code:
#ifndef TOOL_H
#define TOOL_H
#include <QObject>
#include <tool.h>
class Tool
{
// Q_OBJECT
public:
Tool();
Q_INVOKABLE QList<Type*>getStorage();
private:
QList<Type*> typeList;
};
#endif // TOOL_H
The compiling error occurs at line 9:
view->rootContext()->setContextProperty("UReceivedMessage", new Tool);
Code:
#include <QDeclarativeView>
#include <QDeclarativeContext>
int main(int argc, char *argv[])
{
QDeclarativeView *view = new QDeclarativeView();
view->rootContext()->setContextProperty("UReceivedMessage", new Tool);
view
->setSource
(QUrl("qrc:/qml/main.qml"));
view->show();
return a.exec();
}
Re: error: ‘QVariant::QVariant(void*)’ is private within this context
Tool must be a QObject - see setContextProperty() declaration.
Re: error: ‘QVariant::QVariant(void*)’ is private within this context
That's right thanks a lot ! :)