Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor aktarjahan2003's Avatar
    Join Date
    Oct 2008
    Posts
    65
    I need to use same C++ object as type in several QML files.

    in C++ main I have
    qmlRegisterType<ConnectionNotifier>("MyConnectionNotifier", 1, 0, "ConnectionNotifier");

    In qml I have
    import MyConnectionNotifier 1.0
    ...
    ConnectionNotifier
    {
    id: myBtConnotifier
    }

    If I do it in several qml file then it will create many C++ objects that I don't like. Can I pass my own element some how to other qml file that can use it?

    Any other options?

  2. #2
    Nokia Developer Champion gaba88's Avatar
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,692
    hmmm if you make your c++ object a contextProperty in QML than you can use it any number of QML files. Please see the following code to understand what i want to say:

    Code:
    MyCplusplusClass m_MyCplusplusObject;
    declartiveView->rootContext()->setContextProperty("cplusplusobject",&m_MyCplusplusObject);
    now use cplusplusobject in any of the QML files.

  3. #3
    Regular Contributor aktarjahan2003's Avatar
    Join Date
    Oct 2008
    Posts
    65
    Thanks, but if my cpp object emit signal how it can be handled in this case?

  4. #4
    Registered User kusumk's Avatar
    Join Date
    Sep 2011
    Posts
    449
    Hi,

    Please check this link , especially the Receiving signals part, it explains how signals in qml can be caught in c++ and also the same viceversa..

Similar Threads

  1. Use of multiple Active Object Callbacks
    By david4x in forum Symbian C++
    Replies: 14
    Last Post: 2010-08-04, 12:16
  2. Single http connection Object for multiple requests
    By J2me_champ in forum Mobile Java General
    Replies: 4
    Last Post: 2008-03-11, 11:42
  3. Multiple VEVENTs in one VCALENDAR object over WAP
    By delnogal in forum Mobile Web Site Development
    Replies: 0
    Last Post: 2004-10-11, 18:28
  4. Multiple Obex object send via Bluetooth
    By jsstewart in forum Symbian C++
    Replies: 0
    Last Post: 2004-03-02, 22:57
  5. Replies: 0
    Last Post: 2003-08-29, 12:28

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved