including a QML file?

Hey new to waterfalls, I try to include a qml file in my main.qml with the following...

TabbedPane {}

Tab {}

Title: 'corner '.

imageSource: "asset:///icons/coin.png."

Content: part {}

}

}

}

When I try to deploy the project to my phone, it's just has a BlackBerry 10 logo and a black screen.

Hello

'content' property is tiny. It is also a property by default so write ' content: {FileName} "is not necessary, simply write"FileName {} ".

If you have FileName.qml where the page is defined:

Page {
  ...page content...
}

It can be used as follows (by removing the file extension):

TabbedPane {
    Tab {
        title : "tab1"
        description : "This is only shown in the side bar"
        imageSource : "tab.png"
        FileName {          // optionally override some properties here        }
    }
}

QML types should begin with capital letter.

Tags: BlackBerry Developers

Similar Questions

  • 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.

  • 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.

  • 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

  • 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 include a .wav file with vi the use of the application builder?

    Hello

    I am developing an application that uses a .wav file. I want to compress this file along with the vi in an executable so that the end user has a single file to run it.  Is it possible to add the .wav file to the executable using Application Builder? Moreover, to do this, can we configure the path to the .wav file in vi to always search for the file in the installation folder (for example: C:\Program Files\E2C\MSK or according to the user installs the executable folder in)?

    Thank you

    Anvy

    Anvy,

    It is not possible to compile a wav file in an executable file using LabVIEW. You can include the wav file in the project and include it in "still included" in your build script that will copy the file in the folder wav data from your executable file. So it is quite easy to distribute the wav with your exe file, even if the wav is not in the exe file.

    hope this helps,

    Norbert

  • 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?

  • 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.

  • How to use cppObject in several QML files?

    I have a variable cppObject of context set as usual:

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

    QML-> setContextProperty ("cppObject", this);

    And it works very well in the main.qml.

    Problem is that it doesn't work in the second pagetwo.qml of QML files that is created on the fly in main.qml when the button is clicked.

    No idea how access C++ pagetwo.qml?

    Thank you.

    I did an application of simple test to replicate this, but I see "HELLO FROM C++" on two pages:

    hand. QML

    // Navigation pane project template
    import bb.cascades 1.0
    
    NavigationPane {
        id: navigationPane
        Page {
            Container {
                Label {
                    text: injection.testFunc()
                }
                Button {
                    text: "Other page"
                    onClicked: {
                        // show detail page when the button is clicked
                        var page = getSecondPage();
                        navigationPane.push(page);
                    }
                    property Page secondPage
                    function getSecondPage() {
                        if (! secondPage) {
                            secondPage = secondPageDefinition.createObject();
                        }
                        return secondPage;
                    }
                    attachedObjects: [
                        ComponentDefinition {
                            id: secondPageDefinition
                            source: "DetailsPage.qml"
                        }
                    ]
                }
            }
        }
    }
    

    DetailsPage.qml:

    // Navigation pane project template
    import bb.cascades 1.0
    
    Page {
        Container {
            Label {
                text: injection.testFunc()
            }
        }
    }
    

    TestEmpty3.cpp:

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

    ...

    QString TestEmpty3::testFunc()
    {
        return "HELLO FROM C++";
    }
    

    TestEmpty3.h:

        Q_INVOKABLE QString testFunc();
    
  • 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();

  • Several QML files

    Hello

    I'm a developer of Java, Blackberry, and I am trying to learn C++ and QML things, so I have no idea if this is stupid or not.

    I have the assets/qml file, which I configured on my .pro file:

    {lupdate_inclusion}
    SOURCES +=... / Assets/QML / *. QML
    }

    Now I have discovered that I can create custom components, to integrate it on some pages.

    What I want to do now and I tried withou success is:

    How can I use two separate files QML?

    / Assets/QML/pages / *. QML

    / Assets/QML/Components / *. QML

    You can use them just like that, at least, I do not change my project folder.
    qml, you use import "folder_name."
    for example:
    import "preferences."

Maybe you are looking for