Results 1 to 2 of 2

Thread: prototyping qml objects

  1. #1
    Join Date
    Apr 2009
    Posts
    206
    Thanks
    34
    Thanked 2 Times in 2 Posts

    Default prototyping qml objects

    Hello friends,

    is it possible to add method on behalf of prototyping after I create objects with Qt.createQmlObject() which return me an Object implemented in C++.

    Like this for Example:

    var component = Qt.createQmlObject('import QtQuick 2.2\nimport mysoft.labs.myObject 1.0\nMDObject{Component.onCompleted: console.log("MDObjectCreate ok");}',root);

    if(component == null) {
    console.log("error creating object" + component.errorString());
    }
    ...
    component .prototype.testFunction = function()
    {

    console.log("Trigger TEstFunction");
    }
    USeCase afterward:

    component.testFunction();

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

    Default Re: prototyping qml objects

    You could add the function in the code argument that you pass to createQmlObject.

    Qt Code:
    1. var component = Qt.createQmObject('import QtQuick 2.2\nimport mysoft.labs.myObject 1.0\nMDObject{ function testFunction() { console.log("testFunction"); }',root);
    2. component.testFunction();
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    codeman (12th November 2014)

Similar Threads

  1. 3d objects in QT
    By waman.prabhu in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2011, 10:11
  2. Replies: 3
    Last Post: 9th January 2010, 15:47
  3. Using SVG as user interface for fast prototyping
    By benlau in forum Qt Programming
    Replies: 1
    Last Post: 8th January 2010, 12:01
  4. Replies: 7
    Last Post: 18th July 2006, 21:33
  5. How to Use Objects
    By raphaelf in forum Newbie
    Replies: 1
    Last Post: 2nd June 2006, 09:59

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.