Results 1 to 5 of 5

Thread: error: ‘QVariant::QVariant(void*)’ is private within this context

  1. #1
    Join Date
    Nov 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Question 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:

    Qt Code:
    1. QDeclarativeView *view = new QDeclarativeView();
    2. view->rootContext()->setContextProperty("Tool", new Tool);
    3. view->setSource(QUrl("qrc:/qml/main.qml"));
    4. view->show();
    To copy to clipboard, switch view to plain text mode 

    Any help would be appreciated

    Cheers !

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Nov 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: error: ‘QVariant::QVariant(void*)’ is private within this context

    Tool class definition:

    Qt Code:
    1. #ifndef TOOL_H
    2. #define TOOL_H
    3.  
    4. #include <QObject>
    5.  
    6. #include <tool.h>
    7.  
    8.  
    9. class Tool
    10. {
    11. // Q_OBJECT
    12.  
    13. public:
    14. Tool();
    15. Q_INVOKABLE QList<Type*>getStorage();
    16.  
    17. private:
    18. QList<Type*> typeList;
    19. };
    20.  
    21. #endif // TOOL_H
    To copy to clipboard, switch view to plain text mode 
    The compiling error occurs at line 9:

    view->rootContext()->setContextProperty("UReceivedMessage", new Tool);

    Qt Code:
    1. #include <QDeclarativeView>
    2. #include <QDeclarativeContext>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7.  
    8. QDeclarativeView *view = new QDeclarativeView();
    9. view->rootContext()->setContextProperty("UReceivedMessage", new Tool);
    10. view->setSource(QUrl("qrc:/qml/main.qml"));
    11. view->show();
    12.  
    13. return a.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: error: ‘QVariant::QVariant(void*)’ is private within this context

    Tool must be a QObject - see setContextProperty() declaration.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Nov 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: error: ‘QVariant::QVariant(void*)’ is private within this context

    That's right thanks a lot !

Similar Threads

  1. Replies: 1
    Last Post: 4th December 2009, 17:03
  2. QPixmap and QVariant
    By cafu in forum Qt Programming
    Replies: 16
    Last Post: 27th October 2009, 13:23
  3. VARIANT <-> QVariant
    By will49 in forum Qt Programming
    Replies: 2
    Last Post: 26th September 2009, 23:39
  4. QVariant to QAxObject*
    By QDrow in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2008, 09:35
  5. QTextCharFormat and QVariant
    By fullmetalcoder in forum Qt Programming
    Replies: 2
    Last Post: 16th May 2007, 11:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.