PDA

View Full Version : error: ‘QVariant::QVariant(void*)’ is private within this context



qtpat
3rd January 2011, 00:39
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:



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 !

high_flyer
3rd January 2011, 11:29
How is 'Tool' defined?
On which line of the given code is the compile error you get?

qtpat
3rd January 2011, 12:39
Tool class definition:




#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);




#include <QDeclarativeView>
#include <QDeclarativeContext>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QDeclarativeView *view = new QDeclarativeView();
view->rootContext()->setContextProperty("UReceivedMessage", new Tool);
view->setSource(QUrl("qrc:/qml/main.qml"));
view->show();

return a.exec();
}

high_flyer
3rd January 2011, 12:42
Tool must be a QObject - see setContextProperty() declaration.

qtpat
4th January 2011, 13:07
That's right thanks a lot ! :)