Results 1 to 3 of 3

Thread: TypeError: Object [object Object] has no method 'sendData'

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default TypeError: Object [object Object] has no method 'sendData'

    qml file:

    Qt Code:
    1. onClicked:
    2. {
    3. Sender.address = "udpm://239.255.76.67:7687"
    4. Sender.ttl= 0
    5. Sender.channel= "A"
    6. Sender.data= "ddfdsf"
    7.  
    8. Sender.sendData()
    9. }
    To copy to clipboard, switch view to plain text mode 

    .h file:

    Qt Code:
    1. Q_INVOKABLE void sendData ();
    To copy to clipboard, switch view to plain text mode 

    main.cpp file:

    Qt Code:
    1. int main (int argc, char *argv[])
    2. {
    3. QGuiApplication app(argc, argv);
    4.  
    5. const char* ocuui = "OCUUI"; // @uri OCUUI
    6.  
    7. qmlRegisterType <Sender> (ocuui, 1, 0, "Sender");
    8.  
    9. Sender objS;
    10. objS.sendData ();
    11.  
    12.  
    13. QtQuick2ApplicationViewer viewer;
    14.  
    15. viewer.addImportPath("/home....");
    16. viewer.setMainQmlFile(QStringLiteral("..../main.qml"));
    17. viewer.showExpanded();
    18.  
    19. return app.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 
    I am using QtCreator. The thing I find odd is that when I type
    Qt Code:
    1. Sender.
    To copy to clipboard, switch view to plain text mode 
    it shows a list of the members of that class and that list "contains" sendData function.


    What point am I missing? Yes, sendData has been defined in the corresponding .cpp file.

  2. The following 2 users say thank you to TheIndependentAquarius for this useful post:


  3. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: TypeError: Object [object Object] has no method 'sendData'

    You register a type called "Sender", but you don't seem to have an obect of that type.

    Did you want to export the Sender instance objS? In that case look for QQmlContext::setContextProperty()

    Cheers,
    _

  4. The following 2 users say thank you to anda_skoa for this useful post:

    TheIndependentAquarius (30th November 2013)

  5. #3
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: TypeError: Object [object Object] has no method 'sendData'

    Quote Originally Posted by anda_skoa View Post
    You register a type called "Sender", but you don't seem to have an obect of that type.
    _
    That was the exact problem. Thank much.
    Last edited by TheIndependentAquarius; 30th November 2013 at 06:10.

  6. The following user says thank you to TheIndependentAquarius for this useful post:


Similar Threads

  1. Replies: 0
    Last Post: 28th May 2012, 19:56
  2. How to call a function in the mother object from a child object?
    By Momergil in forum General Programming
    Replies: 4
    Last Post: 18th December 2011, 15:49
  3. Replies: 1
    Last Post: 8th November 2011, 22:27
  4. Replies: 4
    Last Post: 15th July 2011, 18:31
  5. Replies: 4
    Last Post: 20th August 2010, 13:07

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.