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();

Tags: BlackBerry Developers

Similar Questions

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

    ...

    }

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

  • How to use an install.xpi configuration file to configure email data

    Manual installation of my e-mail account failed because Thunderbird search my domain name and is not in its database. If my webhost gave me a file of automatic configuration for Thunderbird for my e-mail, called install.xpi - account but how to use this file? I can't double-click them in Windows to do anything. Thunderbird program, he wants to create a new account, but I can't do anything else in it as importing files.

    How to use the install.xpi file so it creates my e-mail account with the appropriate configuration variables? Thanks for your help.

    Launch Thunderbird, close the wizard, goto the Add-ons, select Tools menu (alt + T)

    There is a small button to the left of the search window. Click this button and select install module file and navigate to your xpi file, select it and you leave.

  • How to use the ota installation cod file

    Using the webworks platform, we have the standard and ota install files, I need to know how the cod in the ota installation file can be used.

    Put the web in an accessible location OTA files and point the browser on your phone to the URL.

    That is to say.

    If you download the OTA cod files in a directory named "/ ota/appname" on your server web you acceding to http://your-url.ca/ota/appname/cod-name.cod in the BlackBerry browser to install the application

    Rory

  • How to use ODIOUTFILE to generate a file with the specified permission.

    The syntax will be if I want to use ODIOUTFILE to genreate a file under Linux with permissio to owner and group writing reading?


    Thank you

    Good to know who works!

    Be sure to check the answer himself as correct or useful if it helps you...

    Cezar Santos
    http://odiexperts.com

  • How to use mxf with Premiere elements files?

    Any ideas on how to use my canon xf100 with elements .mxf? In addition, I don't see a setting in menu when I start a project?

    http://www.Google.com/#sclient=psy-AB&hl=en&q=convert+MXF+AVI&OQ=convert+MXF+AVI&AQ=f&AQI= g - v4 & aql = & gs_l = hp.3... 0i15l4.4835.9343.0.12811.15.13.0.2.2.0.168.1138.11j2.13.0... 0.0.EDKQ8 U_mDpc & pbx = 1 & bav = we. 2, or.r_gc.r_pw., cf.osb & fp = e3a93c99a6099aba & biw = 1905 & bih = 701

  • How to use FM OmegaT processed XML files?

    How to convert files in XML (or any other file format that supports the file format that can be used in T Omega) FM so that it can be imported into the translation software open source OmegaT?

    I have a use [Save as] create an XML file, an error message appears when I try to import in Omega T and but I'm unable to translate the file.

    I am trying to use XML files for translation into Omega T, is because in the past, the person who is in charge of editing the file FM would create a text file with sentences to be translated. I would then import the text file in OmegaT to translate and send the text file with the phrases translated to the editor. This could then be edited in a file of FM.

    It would not be a problem if the content to be translated was small. But in some cases there is a large amount of content that must be translated which would take more time to change the FM files.

    What I want to know is if I could use a file format that can be used in Omega T and then be able to convert this file to FM without the Publisher re - edit the file.

    Concerning

    Denjiba-manual

    With regard to the function "Save as XML" in FrameMaker:

    You may know that in FrameMaker, you can work with 'structured' and regular documents.

    When you use "Save as XML" with a document ordinary FM, the resulting XML is simply an output format and are not suitable for reopening in FM. You can translate the XML resulting, but once you return to the FM file, you need to reapply the formatting and the initial numbers back into place. (At least this is what I know of FM8.)

    Otherwise, when you work with an application of structure in FM, you can save documents structured FM in XML format for editing. This means, you can change (translate) the XML document outside FM and open the (translated) XML file published in FM.

    OmegaT regarding:

    I see two ways of translating a document of FM with OmegaT. For both, you will need the Okapi Framework to convert your files into an intermediate format.

    One way requires that your document is a document structured in FM, you can save in XML format for editing. The XML document has probably none of the types of documents that can be translated immediately OmegaT. You can, however, use a utility of the framework of the Okapi to extract translatable text in the XML document in a XLIFF file. Later, you can merge the translated text in the original XML file, which you can bring in FM.

    The other way is similar, but starts with an of FrameMaker MIF file. In this case, regardless of whether or not the document of FM is structured. Of course, there is a MIF Filter for the frame of the Okapi, which allows you to extract the translatable text of MIF in an XLIFF file. Just like above, you can later merge the translated text in the original MIF file. However, the MIF Filter is in beta state, so don't expect it to work perfectly.

    More on the Okapi Framework can be found at http://okapi.opentag.com.

    All that being said, I only played a bit with OmegaT and Okapi. At work, I use an old version of Trados.

    Johannes

  • How to use the recovery partition recovery files in computer hp laptop dv6 in windows 7

    I'm trying to find my laptop to factory settings without using recovery disks in windows 7.
    but using whenever I try to recver in file recovery system in Control Panel, when the computer restarts it says that there is no bootable media or recovery disk.
    When you use the Recovery Manager, it says the system recovery is disabled try to use recovery media creation but the creation of recovery media said that the recovery media has already been created once and it can not be recreated.
    whenever I open the recovery file on the hard drive of the score, he said, this partition is for recovery donot change or remove this partition. He covered about 10 GB of space but whenver that I open it, the file is empty and hp logo appears with instructions that his is set for partition donot change it.
    can someone tell what to do?

    Have the hard drive in the dynamic State breaks the recovery feature. Conversion of back to basics should not delete your data, unless the data is on the extra partition, you have to remove to get the disk hard back to base.

  • Hosts the naming - how to use VMware name instead of file name

    Please see attached file.

    All hosts based on the same models appear under the same name in hosts. Is it possible to configure vFoglight to extract the vCenter appoint to the host instead of using the file name of the VMware disk for guests of actual spending?

    You are looking in the wrong place in the object model.

    Machine virtual VMWare is an extension of the host object model.  Think of the host as the base model by the dealer and the virtual machine as the base model with all the bells and whistles added to make a street racer.

    If you enter a virtual machine name in the top search bar, you will see that the returned results include objects of different types, probably a Machine virtual VMWare and a host.  Select the virtual machine VMWare will take you to the model object VMWare-specific screens.  Similar results for HyperV, etc..

    There is always a host record for each virtual machine, just as each car factory has the model of base somewhere.  He just won't have all the bells and whistles.

    Looking at your attachment, I think that what you see on the dashboard can be what you see in Virtual Center.  Virtual machines have a name that appears on the list of the Virtual Center, which can be separated from the real name assigned to the VM inside the operating system.  If you fix the naming in VC, I think you will find that the correction automatically flows to vFoglight.

  • How to use the date of the file, when you download a file?

    Using the basics of 12 c, APEX 5.0 and IE11

    I am creating a file upload feature for my application.  I'm able to get the upload├⌐ file in my table, but one of my requirements is that I fill in a value in the table with the "file date".

    Is there an easy way to get the "file date" in the file being downloaded and fill a field for all records with this date?

    Tillie

    Tillie says:

    Using the basics of 12 c, APEX 5.0 and IE11

    I am creating a file upload feature for my application.  I'm able to get the upload├⌐ file in my table, but one of my requirements is that I fill in a value in the table with the "file date".

    Is there an easy way to get the "file date" in the file being downloaded and fill a field for all records with this date?

    That depends on your definition of 'easy '...

    The HTML5 File interface can be used to access date in browsers supportthe file was last modified.

    1. Add a hidden page that contains the file download point (P6_FILE_DATE in this example).

    2. create a dynamic action of change on the file upload question (P6_FILE):

    Event: Change

    Selection type: Agenda

    Region:

    Real Actions

    Action: Run the JavaScript Code

    Fire on Page load: NO.

    Code

    console.log('Get file modification date:')
    var fileItem = $x('P6_FILE');
    if (window.File) {
      if (fileItem.files.length > 0) {
        var file = fileItem.files[0];
        if (typeof file.lastModifiedDate !== 'undefined') {
          console.log('...lastModifiedDate for file \"' + file.name + '\": ' + file.lastModifiedDate);
          apex.item('P6_FILE_DATE').setValue(file.lastModifiedDate);
        }
        else {
          console.log('...browser does not support the HTML5 File lastModifiedDate property.');
        }
      }
    }
    else {
      console.log('...browser does not support the HTML5 File interface.');
    }
    

    If the browser has support for the File interface and lastModifiedDate property, the date, the file was last modified will be presented in the P6_FILE_DATE article in the form:

    Fri Jul 17 2015 10:43:44 GMT+0100 (GMT Daylight Time)

    You can analyze and convert your data load process to obtain a TIMESTAMP or DATE value according to the needs.

  • How to use ps to create a file with color gradient png

    I want to design a texture (png file) for a light in 3ds Max. I wish the texture reduce the alpha gradually from top to bottom (from 255 to 0).

    And then I'll see the tear of light will become pure transparency in 3ds Max.

    Could someone knows how to create texture (png file)?

    Attach file is my psd file.

    Hello

    Just follow the steps below.

    1. create a new transparent document.

    2. create a gradient in the gradient panel.

    3. click on Ctrl + S or Ctrl + Shift + S to save and choose the format ".png" file format option

    (If you want to create a transparent gradient then see attached screenshot settings)

    Hope this helps,

    See you soon

    ------------------

    Sindou Puri

    LeXolution IT services as

  • How to use pictures and iMovie video files without duplicates?

    I want to download videos on my computer and have it available on both pictures and iMovie. Do I need to download twice, which seems very ineffective, or is there a workaround?

    It works for me with Final Cut Pro (I think it'll work on iMovie too):

    1. Add video to your photo library.
    2. Go to your pictures folder.
    3. Right-click on "Photo Library".
    4. Press "view the contents of the package.
    5. Go to 'Masters '.
    6. Select the year, month and day, that video was made (you can easily check this in the Photos app by making a right click on the video, then click on 'Get Info').
    7. Drag the specific video in the iMovie app for use with iMovie.
  • How to add comments to several files in the finder using automator?

    I need to add comments to multiple files in the finder. Can I do this using Automator application, without going file-by-file and press command + i to add a comment one by one?

    Hello

    Open the Automator application:

    Select the Service icon

    Create the workflow, as this image

    Save the workflow.

    -----------

    After that, to add comments:

    Selectionner select files in the Finder, right-click on the selected files and select your service in the menu 'Services' in the context menu.

  • How to access the tab 'Save all' when I close several jpeg files that have been adjusted with the "color adjust tool? He is currently making me close and save one at a time. Thanks for any help :)

    How to access the tab 'Save all' when I close several jpeg files that have been adjusted with the "color adjust tool? He is currently making me close and save one at a time.  I've just upgraded to El Capitan.  Thanks for any help :)

    I assume that you use the application overview.

    I can't find an answer to back up everything, but a workaround could be while the file menu options are visible, press the option key

    and the point of the window will become close, if you click on that dialogue will ask you if you want to restore the changes or save

    pressing Save will close the image with the changes and then move to the next image and so on.

Maybe you are looking for