Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User pixsta's Avatar
    Join Date
    Apr 2008
    Posts
    437
    Hi,

    I am using PageStackedWindow on Harmattan. Pages are dynamically loaded from qml files.
    Now, I want to call a method from C++ within a loaded page, for instance function "dummyfnc":
    Code:
    import QtQuick 1.0
    import Qt 4.7
    import com.nokia.meego 1.0 
    Page {
    id: page1
    function dummyfnc() {
    // do something here
    }
    }
    I tried something like this, but it does not work:
    Code:
    QObject *object = (QObject*)m_qmlView.rootObject()->findChild<QObject*>("page1");
    // or
    QObject *object = (QObject*)m_qmlView.rootObject()->findChild<QDeclarativeItem*>("pageStack")->findChild<QDeclarativeItem*>("page1");
    
    QMetaObject::invokeMethod(object, "dummyfnc");
    How can I correctly invoke the method?
    Regards,

  2. #2
    Registered User sapur's Avatar
    Join Date
    Mar 2011
    Posts
    16
    Hi,

    Here is the sample example using signal slots concept for invoking the QML functions. Hope this meets your requirement.

    http://www.developer.nokia.com/Commu...o_QML_function

    Best Regards
    Sapur

  3. #3
    Registered User pixsta's Avatar
    Join Date
    Apr 2008
    Posts
    437
    Thanks, but my problem is not the connection in general, but the connection to a page which is dynamically added to the page stack. As a workaround I am now using a cascade of signals and slots but that's not very convenient. It would be much nicer if I could directly get a pointer to the page from my C++ code.

  4. #4
    Nokia Developer Moderator gnuton's Avatar
    Join Date
    Mar 2009
    Posts
    1,024
    Hi,
    QML IDs are not the same thing than QObject name.
    Set objectName property in your page1 and it will start to work.

    Reference:
    http://doc.qt.nokia.com/4.7-snapshot/qml-qtobject.html

Similar Threads

  1. PageStack pop transition animation
    By HellStranger in forum Russian Developer Forum - Форум Российских разработчиков
    Replies: 4
    Last Post: 2011-12-13, 12:44
  2. PageStack transition animation
    By HellStranger in forum Nokia N9
    Replies: 8
    Last Post: 2011-12-02, 12:10
  3. How to change toolbar buttons in every pageStack page
    By shintu in forum [Archived] Qt Quick
    Replies: 5
    Last Post: 2011-11-06, 16:11
  4. Problem with PageStack - too much memory usage
    By rogeriopaladino in forum [Archived] Qt Quick
    Replies: 4
    Last Post: 2011-10-25, 22:29

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