call a QML file code c ++

Hello.

I am newbie to blackberry 10 development...

actaully I got the credentials to the server and power analyzes the user name and password...

now I have to redirect to the new file qml by c ++.

So I will be gratefull if you guide or help me...

Thanks to anticipate...

You should find a lot of code when you check out the samples.

to send a signal of c ++ you define first the signal in the header. Here's an example, let's say this is in app.hpp:

signals:
    void numberOfItems(int numberOfItems);
    void numberOfItemsError(QString message);

to send the signal in c ++ you write

emit numberOfItems(5);

to receive the signal in QML, you must register at the first class (this is already done when you create a new application of waterfalls).

Just to show you, that it would look like this:

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("app", this);

Qml, you connect the signal to a qml function, for example onNumberOfItems

app.numberOfItems.connect(onNumberOfItems)

the function is executed when the signal is emitted:

function onNumberOfItems(number){
  console.log("number of items: "+number);
}

That should cover it. It gets a little more complicated when you want to send complex objects with the signal.

Tags: BlackBerry Developers

Similar Questions

  • Push CPC QML file?

    Hello guys,.

    Can we push a CPC of QML file? Something like

    ActionItem {
                    title: "Show Next Page"
                    onTriggered: {
                        var page = pageDefinition.createObject();
                        navgationPane.push(page);
                    }
                    attachedObjects: ComponentDefinition {
                        id: pageDefinition
                        source:"sample.qml"
                    }
    
                }
    

    Above code pushes QML file on the user interface. Like, I want to push a PPC on the user interface file.

    Possible solutions please?

    Thank you

    SHA.

    There is no way to give parameters to builders in QML, AFAIK. One option is to assign the default values, such as:
    Constructor (Application * app = NULL,...) so that the item can be built in QML and export these settings as properties too. So I think that the properties can be defined this way:

    content: MyComponentExportedFromCPP {
      property: value
    }
    

    You need to export objects that are used during initialization of QML so. It may be easier to inject the component from C++ code. In this way, you can call a single function in C++ code and create & initialize the object here.

    BTW, the way the Application object between instances of the object is not really necessary. It is a singleton and is accessible from anywhere:

    Application * app = Application::instance();

  • Call .seq Python files

    I'm trying to use Python to call a .seq file, wait until the sequence is done, and then resume the Python script.  I got everything to work it seems however my problem is when I make the Engine.NewExecution seems not to run the movie file and WaitForEndEx to expire. (Time for my movie file is about 50 seconds).

    What I am doing wrong?

    Python code:

    testStandEngine = win32com.client.Dispatch ("TestStand.Engine.1")
    sequenceFileObject = testStandEngine.GetSequenceFileEx ("C:\\...\\SIL Version .13\\Teststand Primitives\\ShutDown Target.seq")
    testStandExecution = testStandEngine.NewExecution (sequenceFileObject, "MainSequence", sequenceFileObject, False, 0)
    testStandExecution.WaitForEndEx (60000)

    Hobbs,

    I am able to call a movie file and get the behavior you expect with the files I enclose you.

    The code is basically the same code that you have, and I just added additional logic to determine the path of the file in sequence automatically (to the zip file so that you can run it) and I removed the client file of sequence setting just so I can see if the sequence is running without the important process templates.

    I've built and run with Python 2.7.1 using win32com 7 February 2012 (I wasn't able to determine where they store the version)

    Hope this helps,

    Francisco

  • Call a help file (.chm) when press a button on the front

    I can't call a help file (.chm) when press a button on the front. I have only called when press a key then right click the mouse and navigate the selected key for the button.

    Call the help file (.chm) when press a butto wrote:
    I have only called when press a key then right click the mouse and navigate the selected key for the button.

    This part is not so clear for me.

    But you have coded according to the part file .chm calling within the event to change the value of this button?

    If not try this using the Structure of the event & post here.

    If you post your code here, someone can help reg what has gone wrong.

  • The Devs creating their active Frame for a separate QML file covers? I'm stuck

    Bit in trouble, I do my best to bring my Apps support 10.2.1 10.2.2 I practically everything by working the * beep * covers Active, I did do a check and create the file QML according to less than 10.3 or greater

     ComponentDefinition {
                id: creator;
                source: ""
                function createQMLObject(sourceUrl){source=sourceUrl; creator.createObject()}
            }
    

    Feel free to use that btw ^.

    if(olderFirmware===true)  Application.setCover(creator.createQMLObject("CoverOlderFirmware.qml"))
            else{Application.setCover(creator.createQMLObject("Cover.qml"))}
    

    Now for some reason, they do not work, they seem to be created, but do not want to show, normally I would create it from my main.qml but the passport and its lid Multi forced me to separate the covers in their own QML files

    Begins like (not included UI code)

    import bb.cascades 1.2
    
        SceneCover {
            id: large
    
            content: Container {
                background: Color.create("#000000")
                layout: DockLayout {}
    }
    }
    

    Place in a container gives me a weird error on not able to create a list in an object, probably referring to MultiCover and SceneCover as a child of the container.

    Any suggestions?

    I use active selector to do this, find in this application example:
    https://github.com/RodgerLeblanc/AssetSelector

    This method can support 10.2.1 users and below, don't forget to add the lines of c ++ this blog:
    https://bb10code.WordPress.com/2014/12/10/active-frame-made-easy/

    Check your email, I also sent you something on your last post on the forum.

  • Is it possible to include a qml file in another file?

    Hello

    I am creating a list as an example of stamp,

    However, all these QML files fall within a records

    what I'm trying to do is to create various QML files, and some of these files are shared within other files.

    for example: I break the code of stampcollectorapp qml,.

                        // Second level item see the component in StampItem.qml.
                        ListItemComponent {
                            type: "item"
                            StampItem {
                            }
                        }
    

    The line to [StampItem] looking for another QML file,

    If I define StampItem in other current folder, how to write and thank you?

                        // Second level item see the component in StampItem.qml.
                        ListItemComponent {
                            type: "item"
                            myqmlpath???/StampItem {
                            }
                        }
    

    I think that you must import them into the upper part of your qml, cites the example of application a qml files in subfolders

    See here:

    https://github.com/BlackBerry/Cascades-samples/BLOB/master/quotes/assets/main.QML

    EditScreen is imported in main.qml, and EditScreen is in assets/EditScreen/EditScreen.qml

    I don't know if the name of the folder is the same as the qml file name is a convention, then I would try to mess around and see what works.

  • Load a sheet from a QML file

    Hi, now I have a sheet of attachedObjects and I open it with mySheet.open ();

    I want to move it to an external QML file to make my code more readable, but it does not work. What should I do?

    Hello

    If you have something like this:

    hand. QML

    attachedObjects: [
            Sheet {
                id: loginSheet
                content: ...
            },
    

    Just move it to an another qml:

    MySheet.qml

    Sheet {
      content: ...
    

    hand. QML:

    attachedObjects: [
            MySheet {
                id: loginSheet
            },
    
  • Animated images in place when loading new QML file

    I noticed that when I insert new QML files, the images Animate into place.

    For example, if the screen contains an image at the position X, Y, and width W and height H, then the image becomes visible at the point of coordinates 0,0-0 width and height 0 and anime then in place by flying over to the X, Y coordinates and more in addition to being finally width W and height H.

    If I then click on the 'Back' button and enter this QML screen a second time, it does not animate.

    This implicit animation is intended?  While the implicit animations are pretty amazing and a great tool to have, it seems intuitive to the use of screens animations implicit when they are first loaded. It creates a rather unpleasant company and Visual distraction when loading screen.

    I thought that I could disable it by adding the following to the ImageView controls:

                    attachedObjects: [
                        ImplicitAnimationController {
                            enabled: false
                        }
                    ]
    

    ... but they are always animate.

    Thank you

    Daniel

    Did you notice the sample code above?  (yes)

    This seems to be fixed with the latest SDK.

  • QSettings, components in other qml files

    As is often the case with parameters, they are on another page in an application of everything. I use QSettings to similarly as the sample application starshipSettings and met the common problem that is the component, a button, etc., is in a file different qml and page in the application, its id and its properties are not recognized. How could this be overcome? I don't know that there is a simple solution that I could see it often to come.

    If there are the superior means of persistent data, I'd be welcome to their learning.

    Yes, if you take a look at the example parameters Starship ( https://github.com/blackberry/Cascades-Samples/tree/master/starshipsettings ) application, you will find the WarpDrive.qml been 'called' inside the main.qml, such as:

            // Component with warp core image and slider with title and tooltip.
            WarpDrive {
                layout: StackLayout {
                    leftPadding: 110
                    rightPadding: leftPadding
                }
            }
    

    After that, you will find the box set also, such as:

    CheckBox {
                    id: uranuscanner
                    text: "URANUS SCANNER"
                    objectName: "uranuscanner"
                    checked: _starshipApp.getValueFor(objectName, "yes")
                    onCheckedChanged: {
                        _starshipApp.saveValueFor(uranuscanner.objectName, checked)
                    }
                }
    

    So if you do a test on the WarpDrive.qml file, change the bellows of the label:

            Label {
                text: "WARP DRIVE SPEED"
                textStyle {
                    base: SystemDefaults.TextStyles.SmallText
                    fontWeight: FontWeight.Bold
                    color: Color.create ("#ff262626")
                }
            }
    

    to something like:

            Label {
                text: _starshipApp.getValueFor("uranuscanner", "")
                textStyle {
                    base: SystemDefaults.TextStyles.SmallText
                    fontWeight: FontWeight.Bold
                    color: Color.create ("#ff262626")
                }
            }
    

    just to read the value of the parameter in the text of the label.

  • To access the properties of QML context through several QML files

    It seems so basic, but I don't see how well...

    I put a 'WebAPI' context property to access my class that makes HTTP requests etc. WebAPI works very well main.qml, but when I try and use it in the included LargeThumbItem.qml I get:

    "LargeThumbItem.qml:37: ReferenceError: can't find variable: WebAPI.

    How to set a context property that is available for * all * my QML files? What is the best practice for this?

    hand. QML

    {

    ...

    {ListItemComponent}

    type: 'point '.

    LargeThumbItem {

    }

    }

    ....

    }

    LargeThumbItem.qml

    {

    ....

    WebAPI.getImagePath (...)

    ...

    }

    I do the usual configuration...

    QmlDocument * qml = QmlDocument::create("asset:///main.qml").parent(this);

    QML-> setContextProperty ("WebAPI", m_pWebAPI);

    I tried calling qml-> documentContext()-> setContextProperty(), but it did not work. Is there a global context that I can put all documents will inherit? (the API documentation seems to suggest there is).

    This problem is related to what is described here and the solution is the same. The problem is that the ListItemComponents have a different context and lifecylce due to the fact that they are cached in and out as the scrolls of the ListView (see here for details).

    I solved it by adding a dynamic property on the global object of 'Qt' for example in onCreationCompleted() or anywhere where the senses in main.qml. In my case, I chose to pass a string, because I don't know if the global property to the instance around WebAPI is a good idea.

    Qt.homeListBaseURL = WebAPI.getImagePath ("TitleImagePathPrefix", "170 x 240")

    Then in LargeThumbItem.qml for example

    {WebImageView}

    ...

    URL: Qt.homeListBaseURL + ListItemData.ContentId + '.jpg '.

    ...

    }

  • Manipulate the object in another QML file

    I have a drop down menu with some functions that modify sldiers Beach

    onTriggered: {}

    Slide1.toValue = 10

    }

    It works fine, but when I move the piece that has the cursor in another qml file and include it like that...

    {MyInclude}

    }

    It stops working. Someone knows why, or how to fix it?

    One option is to give an id to MyInclude:

    MyInclude {
      id: myInclude
    }
    

    And reference it like this:

    myInclude.slide1.toValue = 10
    

    But it is better to create an alias of the upper level in MyInclude.qml property to define a public interface. Pseudo-code for MyInclude.qml:

    Page {
      property alias toValue: slide1.toValue
      ...
      Slider {
        id: slide1
      }
    }
    

    These alias properties can be referenced like this:

    myInclude.toValue = 10

    This is not limited to the alias properties, they can be of any type (int, var, etc.).

  • Declaring new file c ++ for the new qml file

    I have a qml file, the button I click on function Boutonclique clal

    #include "applicationui.hpp"
    #include "homepage.hpp"
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    using namespace bb::cascades;
    
    AbstractPane *root;
    ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
            QObject(app)
    {
    
        m_pTranslator = new QTranslator(this);
        m_pLocaleHandler = new LocaleHandler(this);
    
        bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
    
        Q_ASSERT(res);
        Q_UNUSED(res);
        onSystemLanguageChanged();
    
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // Create root object for the UI
        root = qml->createRootObject();
        if (!qml->hasErrors()) {
    
                qml->setContextProperty("quoteApp", this);
            }
        // Set created root object as the application scene
        app->setScene(root);
    }
    
    void ApplicationUI::onSystemLanguageChanged()
    {
        QCoreApplication::instance()->removeTranslator(m_pTranslator);
        // Initiate, load and install the application translation files.
        QString locale_string = QLocale().name();
        QString file_name = QString("Test1_%1").arg(locale_string);
        if (m_pTranslator->load(file_name, "app/native/qm")) {
            QCoreApplication::instance()->installTranslator(m_pTranslator);
        }
    }
    void ApplicationUI::clickedButton()
    {
    HomePage home = new HomePage(this);
    
    }
    

    Homepage.cpp

    #include "homepage.hpp"
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    using namespace bb::cascades;
    
    HomePage::HomePage(bb::cascades::Application *app):
                    QObject(app) {
    
            m_pTranslator = new QTranslator(this);
            m_pLocaleHandler = new LocaleHandler(this);
    
            bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
    
            Q_ASSERT(res);
            Q_UNUSED(res);
            onSystemLanguageChanged();
                QmlDocument *qml = QmlDocument::create("asset:///homepage.qml").parent(this);
                NavigationPane *myNavi = root->findChild("myNavi");
                if (myNavi == NULL){
                    qDebug() << "Unable find NavigationPane";
                    return;
                }
                Page *new_page = qml->createRootObject();
                if (new_page){
                    myNavi->push(new_page);
                }else{
                    return;
                }
                Application::instance()->setScene(myNavi);
    }
    
    void HomePage::onSystemLanguageChanged()
    {
        QCoreApplication::instance()->removeTranslator(m_pTranslator);
        // Initiate, load and install the application translation files.
        QString locale_string = QLocale().name();
        QString file_name = QString("Test1_%1").arg(locale_string);
        if (m_pTranslator->load(file_name, "app/native/qm")) {
            QCoreApplication::instance()->installTranslator(m_pTranslator);
        }
    }
    

    Homepage. HPP

    #ifndef HOMEPAGE_H_
    #define HOMEPAGE_H_
    
    #include 
    
    namespace bb
    {
        namespace cascades
        {
            class Application;
            class LocaleHandler;
        }
    }
    
    class QTranslator;
    
    /*!
     * @brief Application object
     *
     *
     */
    
    class HomePage : public QObject
    {
        Q_OBJECT
    public:
        HomePage(bb::cascades::Application *app);
        virtual ~HomePage() { }
        Q_INVOKABLE void clickedButton();
    private slots:
        void onSystemLanguageChanged();
    private:
        QTranslator* m_pTranslator;
        bb::cascades::LocaleHandler* m_pLocaleHandler;
    };
    
    #endif /* ApplicationUI_HPP_ */
    

    I get in homepage.cpp root is not declared in this scope. I want to click on the main.qml button, I go to new file c ++ and call homepage.qml

    Hello
    I highly recommend investing a few weeks in learning C++ before learning the stunts. Specifically, these topics:
    -Advance declaring types
    -Memory management
    -Classes & inheritance (different from Java, a lot)
    -Life management object qt (parent/child, order of destruction of object relationship)

    These are essential, but we can't really help with them in the form of forum.

    On the compile error, this should probably fix:

    Homepage * home = new HomePage (NULL);

    But there are other problems in the statement of homepage. It's the manufacturer probably shouldn't take an instance of class ApplicationUI as the parameter.

  • How to call the BB10 file manager?

    Hello

    Is it possible to open a native file bb10 Manager application of webworks? I've not found anything expect the api file picker that is not exactly what I want. I have to just call/open the file manager inside a folder that is created by the app.

    tips are welcome.

    Thank you very much

    No I don't think so. The docs invocation page: Basic applications does not include the application of file manager: https://developer.blackberry.com/html5/documentation/invoking_core_apps.html

    The file picker has been designed to give applications an easy way to activate the file selection.

  • Waterfalls of Beta 4 - cannot change the QML file

    Anyone else unable to edit QML files with the new Cascades Beta 4?

    I can edit in text mode, but the default editor is suspended the IDE when an existing QML file is changed.

    Yes I can. I don't have the QML preview because I use Win 8 64 bit, but the QML perspective opens.

    Have you tried a new clean rather than installing on Beta 3 installation?

  • qsTr works does not in all qml files

    any idea?

    in one of my translation of applications inside QML using qsTr ("my text") works only in main.qml.

    all the other qsTr (...) is ignored.

    but this does not happen always - in other applications it works

    thx for the advice

    Make sure that you update the .pro file to include directories from the other qml files. By default, it includes only the root directory of liabilities

Maybe you are looking for