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();
Tags: BlackBerry Developers
Similar Questions
-
Call one item id of one QML file to another?
I want of missing me something obvious here so if someone could help please...
I would like to appeal/manipulate an element that is not in the same file as signal qml. So for example if I have:
hand. QML:
... Button{ ... onClicked{ label5.text = "Hello World" } } ...
otherfile. QML
... Label{ id: label5 text: "" } ...
How can I do this? If I do what I have above nothing happens because it is looking for somethng named label5 in main.qml and not trying to otherfile.qml. I guess if it's possible I need to put extra code into each file to expose the elements to each other right?
Hello
You will need to provide an alias for this Label. Pushed.QML
import bb.cascades 1.0 Page { property alias label5 : label5 Container { layout: DockLayout {} Label { id: label5 text: "Hello World" } } }
Then you need to join one where you want to access Label5 this qml: main.qml
import bb.cascades 1.0 NavigationPane { id: nav Page { Button { onClicked: { pushed.label5.text = "changed" nav.push(pushed) } } } attachedObjects: [ Pushed { id: pushed } ] }
Here, I wanted to check if the text gets changed or not so Im pushing that qml to see 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();
-
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.
-
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/AssetSelectorThis 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.
-
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?
-
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.
-
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 '.
...
}
-
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." -
Waterfalls in charge of javascript in the qml file
Cascades does support javascript in the qml file? If Yes please let me know how to use js in qml file.
Something tells me that you could not start by checking all the introductory documents. :-)
https://developer.BlackBerry.com/Cascades/documentation/dev/index.html should help you get started, especially the section he titled "JavaScript in QML.
-
Communication problems between the QML files
I'm trying to divide my request of 1 QML file to a bouquet.
I have problems with the East,
OtherQml.qml
import bb.cascades.1.0 Container { id: root property alias otherRoot: root property bool customBool Container { id: otherContent onTouch: { if (event.isUp(){ customBool = true; } } } }
hand. QML
import bb.cascades.1.0 Page { Contianer { id: root OtherQml { id: otherQml onCustomBoolChanged: { if (! true) { root.background = Color.Red; console.log("customBool is: " + cusotmBool); } else { root.background = Color.Blue; customBool = false; //the false signal isnt recieved by OtherQml.qml console.log("customBool is: " + customBool); } } } } }
the false signal is not received by OtherQml.qml so the functions are not able to run one time or as in this example, the background to red
Hello!
if (! true) {
is always false, it should be if (! customBool) {}
Also, there is a typo in ("cusotmBool"):
console.log("customBool is: " + cusotmBool);
Maybe you are looking for
-
ENVY 700-410xt: dual band wireless network card works in my PC?
Hello I would like to replace my Broadcom BCM43142 802.11bgn single band card with a dual band card. I spent a few hours struggling with online help, nothing helps. So called technical support, answered many questions, I was told I would be transferr
-
IDE to USB external hard disk not detected
Convert old IDE hard drive of the laptop HP USB. The drive uses two USB ports for the detection and power. The car worked well for a long time and now with recent updates, MS, AVG and so forth that the hard drive USB - IDE is no longer detected. This
-
How to select the band in the 5 GHz for AE1000?
The product documentation for the said AE1000 you can select which group to use. However it does not seem to be an option to do. I have an E4200 and when I put in place, he gave my band 5 GHz and 2.4 GHz the same SSID. If I configure the AE1000 to co
-
Cannot connect using NetGear WG311 v3 adapter
I had to use a card WG311 v3 installed on a second computer Dell. It recognizes all secured and unsecured in the neighborhood networks, but does not connect. My main computer, also a Dell, is hooked up to a WRT54G using personal WPA for encryption.
-
Try to test my first app ' hello world ' on my BB Q10. Constantly get this error message when you try install app test design: [INFO] Selected target phone[INFO] Error: Unable to connect: connect to /169.254.254.5:443 has expired. Check the settings