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.

Tags: BlackBerry Developers

Similar Questions

  • 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

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

  • 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();
    
  • 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."

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

  • MacBook pro work leave because of pulled and broken wire.  I took out the hard drive.  the hard drive has all my files that I wouldn't need to clear all of the other personal files?

    MacBook pro work leave because of pulled and broken wire.  I took out the hard drive.  the hard drive has all my files that I wouldn't need to clear all of the other personal files?

    It does not start to the top, screen and hardware ok except belt disconnected.

    also can I sell adapter, brand new, never used. where can I sell?

    Hi Wally, the hard disk OS X and all of your files. Get a case for your reader, and it backs up. Try OWC

    Always keep your Mac backed up on an external drive with Time Machine or utility of cloning like SuperDuperor double clone.

    Try eBay for the adapter.

  • Multimedia player that allows some of my WAV files to be played in a more quick read but other WAV files are NOT allowed to read at a faster speed.

    original title WAV file: windows media player

    Multimedia player that allows some of my WAV files to be played in a more quick read but other WAV files are NOT allowed to read at a faster speed.  Any suggestions on how to fix?

    Thank you

    Hello
    1 did you change on your computer before this problem?
    2. what happens when you try to play?
    3. what operating system is running on your computer?

    What version of the operating system Windows am I running?
    http://Windows.Microsoft.com/en-us/Windows7/help/which-version-of-the-Windows-operating-system-am-i-running
    Follow the suggestions and see if it helps.

    Method 1

    You can run Windows Media Player settings convenience store.
    Open the troubleshooting Windows Media Player settings Troubleshooter
    http://Windows.Microsoft.com/en-us/Windows7/open-the-Windows-Media-Player-settings-Troubleshooter

    Method 2
    You can read the article and then check.
    Change playback speed in Windows Media Player
    http://Windows.Microsoft.com/en-us/Windows7/change-playback-speed-in-Windows-Media-Player

    See also:
    Play an audio or video file: frequently asked questions
    http://Windows.Microsoft.com/en-us/Windows7/play-an-audio-or-video-file-frequently-asked-questions
    Play an audio or video file
    http://Windows.Microsoft.com/en-us/Windows7/play-an-audio-or-video-file

     
  • How can I connect Windows XP to several networks, Wi - Fi for internet and the other for file sharing?

    On windows XP, I need to connect to two different networks. Free wifi for the internet and the other for file sharing.

    Different gateways, different static address, same subnet mask. But there is problem when operating simultaneously and must

    a network must be disabled. Is it possible to run simultaneously?

    original title: served various networks simultaneously on windows xp

    Go to where you have configured the static IP addresses for your network adapters.  Leave the "default gateway" blank for your local file sharing adapter and insert a valid default gateway for your wifi Internet adapter.  Of course, this will limit your adapter in a single subnet - which should be OK for use at home or small office to share local files.

    This should work as long as the two physical subnets have two different subnet numbers. In general, this means that the first three digits of the IP address of the adapter can not be the same on both adapters - if they are, then you need to make one of the subnets. (i.e. one is 192.168.1.xxx and the other would be 192.168.2.xxx).  This is usually accomplished in the router configuration page.

    HTH,
    JW

  • Problems with playback of .mpg files & other video files

    Hello:
    All of a sudden I couldn't read the. MPG files (like other video files. AVI are reading OK!) : I have not had any similar problems with him before!  I checked briefly setting CODECs, but did NOT find anything wrong. I also found the following:

    -Receive an error message "the parameter is incorrect" when I try to open any video file EXCEPT. FLV files: all the other video files cannot be opened by the player 'Crazy' 'MEDIA PLAYER CLASSIC - Home Cinema' that literally blocks the use of the Windows Media Player - what an intrusion by the player "MEDIA PLAYER CLASSIC - Home Cinema" against the wishes of the user.

    -J' always set up as the DEFAULT program for most of the video-Windows Media Player files and I DESPISE any program that dares to change these settings of the PC user.

    I would be very happy if someone can help me with the following:

    -What is the cause of MOST OFTEN of such unexpected problems with the PLAYBACK of VIDEO FILES
    -How to make Windows Media Player troubleshooting to RESTORE the original settings for the opening of the video files: there seems to be EXTREMELY disorganized and deficient/little clear instructions by Windows HELP how effectively restore the functioning of Windows Media Player - have Version 11.0.6002.18311 (Pentium IV with VISTA Home Premium).

    Thank you.

    Hello thorsak,

    I suggest reviewing the responses in this thread, because they seem to relate to what you're asking:
  • 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.

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

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

    ...

    }

Maybe you are looking for