Store a NavigationPane as a QML property
I have code similar to the following places:
onTriggered: { var chosenItem = dataModel.data(indexPath); var detailPage = detailsPageDefinition.createObject(); detailPage.initDetailsPage(chosenItem); // Push the content page to the navigation stack main_list_nav.push(detailPage); }
detailPage must also push the NavigationPane, but the problem is I have a couple of different NavigationPanes and the detailPage knows not only push you on.
I want to be able to switch the navigation as the parameter pane to initDetailsPage() i.e.
detailPage.initDetailsPage(chosenItem, main_list_nav);
But how I declare this as a property? by DetailsPage.qml
Page { propertynavigationPaneToUse function initDetailsPage(item, navPane) { navigationPaneToUse = navPane ... } }
If not, is there a property QML on a Page that tells it what NavigationPane he pushed to?
Thanks for all the help guys. Suite suggested Zmey using the idea of the .parent property and generalizing javayoung above, I came up with this method I set on my UI root object, if it's available everywhere.
It crosses just to the top of the tree of the child until it finds an ancestor with an object name that contains "NavigationPane", then push on that. In this way, that you don't need to store anything.
function pushToParentNavigation(child, objToPush) { var cur = child; while(cur != null && cur.objectName.indexOf("NavigationPane") == -1) { cur = cur.parent; } if(cur.objectName.indexOf("NavigationPane") != -1) { cur.push(objToPush); } else { console.log("No NavigationPane in heirarchy!"); } }
So now I can just do this anywhere:
// Push the content page to the navigation stack this page belongs to. pushToParentNavigation(this_page_id, myUIObject);
This means that you must add objectName: '
Tags: BlackBerry Developers
Similar Questions
-
JS function as a type of page in QML property
Hi all
I'm trying to create useful js 'class' for my blackberry application and save here some information about qml object here is the example of such file js:
/* * my js */ function Utils(devInfo){ this.devInfo = devInfo; this.text = "test text"; this.getInfo = function(){ return this.text; };}
I want to group some utils functions here and use this js in qml file object, but I don't want to create "Utils" every time, I would like to have a single instance of page qml. I tried to use properties:
import bb.cascades 1.3 import com.example.bb10_samples_states 1.0 import "myscripts.js" as Scripts Page { property variant utils : new Scripts.Utils(deviceInfo) Container { Label { id: myLabel text: "Hello World" } onTouch: { var newLabeltext = utils.getInfo(); // freezing myLabel.text = newLabeltext; } } attachedObjects: [ DevInfo{ id: deviceInfo } ] }
* DevInfo is registered object c ++
I got the following in the notecard event error message:
"asset:///main.qml:15: TypeError: result of expression 'utils.getInfo' [[object Object]] is not a function."
If I do not use the property and only with variable work, everything is ok. The following code works correctly:
import bb.cascades 1.3 import com.example.bb10_samples_states 1.0 import "myscripts.js" as Scripts Page { //property variant utils : new Scripts.Utils(deviceInfo) Container { Label { id: myLabel text: "Hello World" } onTouch: { var utils = new Scripts.Utils(deviceInfo); var newLabeltext = utils.getInfo(); myLabel.text = newLabeltext; } } attachedObjects: [ DevInfo{ id: deviceInfo } ] }
In general, I don't know where I can store object js in qml page to access my functions utils without need to create each time. Any ideas?
I think I found the answer
According to this link, there is no global js object and every instance of component QML has own unique copy resources imported from JS:
...
Code-Behind implementation resources
Most of the JavaScript files imported into a document QML are implementations with State of the QML importation document. In these cases, each instance of the QML object type defined in the document requires a separate copy of the JavaScript and State objects to behave properly.
The default behavior when importing the JavaScript files must provide a unique and isolated copy for each instance of the QML component. If this JavaScript file any resources or modules with a statement .import, its code will be executed in the same scope as the instance of the QML component and therefore can access and manipulate objects and properties declared in the QML component. Otherwise, it will have its own unique scope, and the objects and properties of the QML component should be passed to the JavaScript file as parameters functions if they are required.
...
http://Qt-project.org/doc/Qt-5/qtqml-JavaScript-resources.html
So it seems there is no need to implement the model of sigleton or store JS resources in the QML document. I changed my code as follows:
/** * js */ var utils = { devInfo : null }; function init(deviceInfo){ utils.devInfo = deviceInfo; }; function getText(){ return utils.devInfo + " done."; };
and qml:
import bb.cascades 1.3 import com.example.bb10_samples_states 1.0 import "myscripts.js" as Scripts Page { Container { Label { id: myLabel text: "Hello World" } onCreationCompleted: { Scripts.init(deviceInfo); } onTouch: { myLabel.text = Scripts.getText("Tra-ta-ta"); } } attachedObjects: [ DevInfo{ id: deviceInfo } ] }
It works fine - I can store information in the variable 'utils' and work with qml js objects. Hope so, it will help someone
-
Change the contents of cell based selector QML property in container QML
I have a selector in which I want to have the text in each cell selector display in one of two ways, depending on the State of another control in the QML that surrounds the selector and the other controls.
My first attempt used only a QML based Picker with PickerItemComponents. The PickerItemComponents had their text property set to the return value of a utility JS function that takes two arguments - the PickerItemData extracted string and an indicator a boolean to indicate the JS function how to change the string returned to display in the cell of the selector.
When I try to spend a QML property set on the selector for JS calls in the PickerItemComponents, I get an error log saying:
"" ReferenceError: can't find variable:
". I assume here that a PickerItemComponent is missing the context of the selector containing the same way that a ListItemComponent is not the context of the parent company of the ListView. However the docs of PickerItemComponent do not seem to set all of the properties that I could use similiarly to the ListItem.view property, which is ListItemComponent. (In fact, the PickerItemComponent docs don't same spec property of pickerItemData - it only appears in example code).
So the next thing I plan extends the C++ PickerProvider class. However, it seems that this class inherits QObject, not so I don't know if once I go to the trouble to write and expose my own version, I'll be able to finally get the QML of the container including down in the correct callback inside my custom PickerProvider.
Anyone who has been in this way, please share your experience/solution you are able - thanks!
You can try @simon_hain replica of this thread
http://supportforums.BlackBerry.com/T5/native-development/using-QProperty-for-a-label-inside-list-VI... -
CODE "NavigationPane.deprecatedPushQmlByString ("QMLFile.qml")' FAIL
Hey everybody,
IM creating the menu for my application system.
NavigationPane {} with multiple pages.
NavigationPane { id: navigationPane Page { Container { background: Color.Black layout: AbsoluteLayout { } ImageView { id: imageViewID imageSource: "asset:///images/LogoNewsChannel.png" scalingMethod: ScalingMethod.Fill translationX: 210.0 translationY: 250.0 scaleX: 2.0 scaleY: 2.0 } Label { text: "News Channel_BB10" translationX: 220.0 translationY: 40.0 scaleX: 1.5 scaleY: 1.5 textStyle { base: SystemDefaults.TextStyles.BigText fontWeight: FontWeight.Bold color: Color.Yellow } } Button { id: button1 text: "Noticias" imageSource: "asset:///images/LogoNewsChannel.png" layoutProperties: AbsoluteLayoutProperties { positionX: 10 positionY: 800 } onClicked: { navigationPane.deprecatedPushQmlByString("noticias.qml"); } }
This maim.qml call to other pages to make the action but when I push the 'low' for example, notice the application is no not anything. I had read that these codes NavigationPane.deprecatedPushQmlByString ("QMLFile.qml") had been kidnapped.
I tried with navigationPane.push (QMLFile.qml); but any
How can I do to call or call the calibrated page open aplication but run only the home page
Thank you
I followed the instructions
Button { id: button1 text: "Noticias" imageSource: "asset:///images/LogoNewsChannel.png" layoutProperties: AbsoluteLayoutProperties { positionX: 10 positionY: 800 } onClicked: { var page = pageDefinition5.createObject(); navigationPane.push(page); } attachedObjects: ComponentDefinition { id: pageDefinition5; source: "noticias.qml" }
but does nothing, if anyone has any other form... I keep calling the main.qml page
-
How to connect the ButtonClick events to NavigationPane.popAndDelete within QML
Hi all
I know to connect my click event of the button to NavigationPane.popanddelete in the native SDK,
I want to implement this feature in QML, how to implement it.
My struct QML is something like this:
P
MyHeader.QML Container{ Button{ objectName:"BackButton" onClicked:..//how to write here } } MyPage.QML Container{ MyHeader{ } Container{ } } within C++ QmlDocument *qml = QmlDocument::create("MyPage.qml"); AbstractPane *mypage= qml->createRootNode
(); // Button *button = alertPage->findChild Thanks in advance...
Hello
I want everything first, make sure that you know about the properties of the component in QML. If you have inserted a page in your navigation pane and want to have a back button seems natural, you can use the following code in your definition of QML Page {}:
paneProperties: {NavigationPaneProperties}
ButtonBack: {ActionItem}
Title: 'Back '.
onTriggered: {}
_navPane.pop ();
}
}
}This will insert a lower bar filled with a previous button following a consistent style.
If you want to raise the pop event from the QML document via manual button (no), in the property of your onClicked button, you can simply call pop on the handle of your navigation pane.
for example
Button {}
ID: buttonTest
objectName: "buttonTest.
text: "text".
onClicked: {}
_navPane.pop ();
}Please note that in both cases, you have exposed the handle of "_navPane" in your C++ code with subsequent calls (assuming that m_SidePaneContentQML is the name of your page with the back button):
m_SidePaneContentQML = QmlDocument::create().load("SidePane/SidePane.qml");
m_SidePaneQmlContext = m_SidePaneContentQML-> documentContext();
m_SidePaneQmlContext-> setContextProperty ("_navPane", m_Nav);In this case, m_Nav would be the navigation pane that you use.
Let me know if you need more information, I'm happy to help you.
Good luck!
Martin
-
How Textfield text on another page qml property access
Hello
I started 10 BB development recently and need help. I searched this forum but could not find some information exactly related to my problem (unlike only), or I missed something from basically. My main.qml, I want to access the text property of the textfield of the InputControl.qml to be used as a parameter in my SQLQuery (attached object). I tried to use the fieldname method alias property, but it does not work. I can't feature outside. Here is my code:
hand. QML
import bb.cascades 1.4 import bb.cascades.datamanager 1.2 import bb.system 1.0 import bb.data 1.0 Page { id: root titleBar: UIControls { } //! [0] content: Container { leftPadding: ui.du(2) rightPadding: ui.du(2) topPadding: ui.du(2) bottomPadding: ui.du(2) InputControl { } // The ListView that's used to display the artist data //! [1] ListView { id: myListView //property variant dq: defaultDataQuery // Associate the list view with the data model that's defined in the // attachedObjects list layout: StackListLayout { headerMode: ListHeaderMode.Sticky } layoutProperties: StackLayoutProperties { spaceQuota: 1.0 } horizontalAlignment: HorizontalAlignment.Fill verticalAlignment: VerticalAlignment.Fill listItemComponents: [ ListItemComponent { type: "item" Container { Label { text: ListItemData.Japanisch layoutProperties: StackLayoutProperties { } topMargin: 5.0 textStyle { base: SystemDefaults.TextStyles.TitleText fontWeight: FontWeight.Bold color: Color.create("#7a184a") } } Label { text: ListItemData.Lesung textFit.maxFontSizeValue: 9.0 textStyle { base: SystemDefaults.TextStyles.TitleText fontWeight: FontWeight.Normal color: Color.create("#ff1818e9") } } Label { text: ListItemData.Deutsch textStyle { base: SystemDefaults.TextStyles.TitleText fontWeight: FontWeight.Normal } multiline: true textFit.maxFontSizeValue: 8.0 } Divider {} }// Container } // Use a standard list item to display the data in the model ] } // end of ListView }//![1] attachedObjects: [ //! [2] // One of the default provided DataModel's GroupDataModel { id: dataModel grouping: ItemGrouping.None }, DataSource { id: dataSource // Load the data from an SQL database, based on a specific query source: "WadokuJT.db" //query: "select Japanisch, Deutsch, Lesung from WadokuJT where Deutsch like '%Wasser%'" query: "select Japanisch, Deutsch, Lesung from WadokuJT where Deutsch like '%" + stext + "%'"; onDataLoaded: { // After the data is loaded, insert it into the data model dataModel.insertList(data); } type: DataSourceType.Sql } // end of DataSource ]//! [2] actions: [ //! [8] ActionItem { title: qsTr("Search") imageSource: "asset:///images/ic_search.png" ActionBar.placement: ActionBarPlacement.Signature onTriggered: { myListView.dataModel = null dataSource.load() //myListView.dq = defaultDataQuery myListView.dataModel = dataModel } }, ActionItem { title: qsTr("Settings") imageSource: "asset:///images/ic_settings.png" onTriggered: { } }, ActionItem { title: qsTr("Help") imageSource: "asset:///images/ic_help.png" onTriggered: { } } ]//![8] } // end of Page
And here is my InputControl.qml
import bb.cascades 1.4 Container { property alias stext: txtSearchText.text Label { id: lblSearchText text: "Searchtext\r\n" } TextField { id: txtSearchText layoutProperties: FlowListLayoutProperties { } hintText: "Enter Searchtext" } }
Any help is greatly appreciated. Thank you.
Give InputControl an id (in main.qml), for example someId.
Access the variable an alias like someId.stext
-
QML property after onCreationComplete is called?
Hey all,.
I try to send an ID of one QML page into another using properties. On the second page, I want to put a list with data corresepoding to the ID that was passed along.
This is the top of the page that is being created and the
{Page}
property alias workoutname: root.workoutName
property alias workoutid: root.workoutIDIt is the container that contains the list view
{Of container
ID: root
property int workoutID:-1
"" workoutName variant property:It's the onCreationComplete of the Page that has the ID passed in
onCreationCompleted: {}
segmentList.dataModel = _Dal.GetListOfWorkoutSegments (root.workoutID);
}The problem is when onCreationComplete is called the root.workoutID is always-1 instead of the value as defined when I created the page?
Creation of the page below.
page var = workoutPage.createObject ();
page.workoutid = id
page.workoutname = name
homeNavigationPane.push (page);I add these pages through a ComponentDefinition.
Thank you in advance.
-J
It's expected behaviour
You can do this way:
page var = workoutPage.createObject ();
page.workoutid = id
page.workoutname = namepage.init)
homeNavigationPane.push (page);.. .and inside yopur page you have a
function init() {}
where you can use your properties
-
CreateObject QML property binding
Hello, I use the createObject command to dynamically create objects on a qml page, I can do that, but now I want some properties of the dynamically object objects to bind on some properties of the parent, how it is possible?
Greetings silajm
Try the following detour
1 make sure you have your parent properties loan (try also to declare them as alias just to be sure)
2 use the parent properties during the construction of the object in the format: parent.property (or same parent.parent...)
3 createObject(explicit parent id)
It should work. In the case where it does not have to launch your actions onCreationCompleted where I am sure that you will get parent.property.
Try and tell us.
-
Can not access the context in QML property
So I have an arraydatamodel in the CPP file, I use qml-> setContextProperty (...) to set it up to allow QML to access, the strangest part is, no matter if I put it in navigationPane Page or a container, it keeps saying can't find not variable, but in the same QML in ListView, they can access it without a problem. The other weird part, it is an another QML is able to access it in the tag of the page, the same model.
By default of the Jun 02 9000 REVIEWS asset:///main.qml:24 09:12:59.416 com.example.IntervalTimer1.testDev_ervalTimer1a7a2c2e2.427733134: ReferenceError: can't find variable: eventsModel
By default of the Jun 02 9000 REVIEWS asset:///main.qml:110 09:12:59.416 com.example.IntervalTimer1.testDev_ervalTimer1a7a2c2e2.427733134: ReferenceError: can't find variable: eventsModelHere is my code
import bb.cascades 1.0 NavigationPane { id: navigationPane backButtonsVisible: false // Javascript definition function udpateTotalTimeLabel() { console.log("In updateTotalTimeLabel function"); var totalHour = 0, totalMinute = 0, totalSecond = 0; // To debug javascript object print function var print = function(o) { var str = ''; for (var p in o) { if (typeof o[p] == 'string') { str += p + ': ' + o[p] + '; '; } else { str += p + ': { ' + print(o[p]) + '}'; } } return str; } console.log("EventsModel: " + eventsModel.size()); for (var i = 0; i < eventsModel.size(); i ++) { var currentEvent = eventsModel.data([ i ]); console.log("EventsEvent: " + currentEvent["EventName"]); totalHour += currentEvent["EventHour"]; totalMinute += currentEvent["EventMinute"]; totalSecond += currentEvent["EventSecond"]; } if (totalHour < 10) totalHour = "0" + totalHour; if (totalMinute < 10) totalMinute = "0" + totalMinute; if (totalSecond < 10) totalSecond = "0" + totalSecond; totalTimeLabel.text = totalHour + ":" + totalMinute + ":" + totalSecond; } function onDataReady() { console.log("Received DataReady signal"); navigationPane.udpateTotalTimeLabel(); newEventSheet.close(); } Page { id: root titleBar: TitleBar { title: "Interval Timer" } ..... onCreationCompleted: { navigationPane.udpateTotalTimeLabel(); console.log("No of EventsModel: " + eventsModel.size()); console.log("In sheet creationCompleted"); mainObj.dataReady.connect(navigationPane.onDataReady); } }
In the PRC
// Default empty project template #include "applicationui.hpp" #include
#include #include #include "CountdownTimer.hpp" using namespace bb::cascades; ApplicationUI::ApplicationUI(bb::cascades::Application *app) : QObject(app) { // create scene document from main.qml asset // set parent to created document to ensure it exists for the whole application lifetime QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); // Initialize the Array Data Model for holding events this->eventsModel = new ArrayDataModel(); // For Testing only QVariantMap event; event["EventName"] = "Event1"; event["EventHour"] = "00"; event["EventMinute"] = "01"; event["EventSecond"] = "02"; this->eventsModel->append(event); // create root object for the UI AbstractPane *root = qml->createRootObject (); // Registering the QTimer type to QML qmlRegisterType ("TimerLibrary", 1, 0, "CountdownTimer"); // Setting the access for QML to member variable qml->setContextProperty("eventsModel",this->eventsModel); qml->setContextProperty("mainObj",this); // set created root object as a scene app->setScene(root); } ..... void ApplicationUI::refreshData() { emit dataReady(); } Thank you.
The fixed.
You must call setContextProperty before calling createRootObject.
-
Setting a QML property in another file
I'm pretty new to stunts, so I hope someone could help me with this. This piece of code is supposed to load main.qml, with a button to open a separate sheet (CountryList.qml). On this sheet, it loads a local XML database in a ListView. The user selects one of the items in the ListView, which is supposed to give selectedcountry.text. How would we do that last one?
hand. QML:
import bb.cascades 1.2 Page { Container { Button { text: "Pick a country" onClicked: { countryList.open() } } Label { text: "Selected Country: " } Label { id: selectedcountry text: "" } } attachedObjects: [ CountryList{ id: countryList } ] }
CountryList.qml:
import bb.cascades 1.2 import bb.data 1.0 Sheet { id: countryList content: Page { titleBar: TitleBar { title: "Pick a Country" dismissAction: ActionItem { title: "Close" onTriggered: { countryList.close() } } } Container { Header { title: "List of countries" } ListView { id: listView dataModel: repoDataModel listItemComponents: [ ListItemComponent { type: "header" Container { Label { text: "" } } }, ListItemComponent { type: "item" Container { Label { text: ListItemData.countryname } Label { text: "Capital: " + ListItemData.capital textStyle.fontSize: FontSize.Small } Divider { } } } ] onTriggered: { //Something should go here } } } } attachedObjects: [ GroupDataModel { id: repoDataModel sortingKeys: [ "countryname" ] sortedAscending: false grouping: ItemGrouping.ByFullValue }, DataSource { id: repoDataSource remote: true source: "countries.xml" query: "repo/country" type: DataSourceType.Xml onDataLoaded: { repoDataModel.clear(); repoDataModel.insertList(data) } } ] onCreationCompleted: { repoDataSource.load(); } }
onTriggered() your worksheet should issue a
signal countrySelected (country)
and the opening Page of the sheet must connect to this signal
a function such asfunction onCountrySelected (country) {}
selectedcountry. Text = country
}
your current solution always sets the value - even if the user does not select something and only closes the leaf
This must be decoupled
-
Broken defaultSaveFileNames FilePicker component QML property?
I'm trying to use a FilePicker to back up and restore user data in a JSON file. I'm the pre-population of the property with the name of the file defaultSaveFileNames is to have its extension (".json") removed when the UI FilePicker slides in on the application user interface. Is - this just broken? There is a thread WebWorks describing the same problem here:
FilePicker { id: backupRestoreFilePicker type: FileType.Document directories : ["/accounts/1000/shared"] viewMode: FilePickerViewMode.ListView defaultSaveFileNames: ["userData.json"] onFileSelected: { // handler code omitted } }
The FilePicker UI does is display "userData" as suggests recorded file name.
He adds the .json at the end of the file name, it it just hides the Textinput
I use it and it adds .bar at the end of the file name, the user types into:
{FilePicker}
string saveName property
ID: saver
defaultSaveFileNames: ['.bar']
mode: FilePickerMode.Saver
Title: "download the update.
directories: [' / accounts / "] -
I cant store files ' t in my CC property
Hi I have a photography of clouds creative plan, but active, I can't download files.
CC said: 100% used = 13.91 GB of 2 GB.
I deleted all the files that were there, but still in error.
What I can to get back work?
Thank you
Links for synchronization of files that can help... all the links I have, since I don't know your specific problem
FAQ - https://forums.adobe.com/thread/1937790
-https://forums.adobe.com/community/creative_cloud/host_sync
-http://helpx.adobe.com/creative-cloud/help/sync-settings.html
-http://helpx.adobe.com/creative-cloud/kb/arent-my-files-syncing.html
-Size limits https://forums.adobe.com/thread/1488242
-sync and send a link http://forums.adobe.com/thread/1427516?tstart=0
-Record ghost https://forums.adobe.com/thread/1490445 problem
-an overview of https://assets.adobe.com/files assets
-File sharing https://forums.adobe.com/thread/1838790
-
Hi all
I need to return the value of the property QML in C++ code, problem is that this value is object of bb::cascades:Control
Look at the example:
import bb.cascades 1.2 Page { property NavigationPane currentNavigationPane: tab1.navHandle property int testprop:0 }
In C++, I need to retrieve the value of currentNavigationPane property (I suppose it must point to NavigationPane *)
QVariant const prop=__current_page->property("currentNavigationPane"); NavigationPane* nav_p=prop.value
(); if (nav_p!=NULL){ qDebug()<<"nav_p is not NULL"; } qDebug()< As a result of this code: nav_p is the null pointer and app crashes without any note of debugging on qDebug()<>
I found the solution by Exhibitor class c ++ in QML and I can call its methods with pointer to bb::cascades:Control as a parameter
QML
Page { id:this_page onCreationCompleted: { mainCPP.UpdatePage(this_page); } }
C++
Q_INVOKABLE void UpdatePage(bb::cascades::Page *call_back_page){ if(call_back_page){ qDebug()<<"Page is valid"; } }
By this method, I can use control of Cascade in C++
-
Property of block size of the data store
How to get the block size defined in the configuration of the data store tab. Is there a property, I should be looking. Currently, I tried getting the object managed data store but were not able to get the size of the block that.
If you are looking for the solution with PowerCLI, take a look at Re: version list VMFS and block size of all data stores
André
-
I'm trying to rewright of my JavaScript application to C + c++ / QML. I'm new to QML, but I thought it wise to write the UI in a QML and then the logic and the C++ user interface controls. The problem I see is when I call the function pop() of C++, the screen never appears. Someone at - it ideas?
Main.cpp
#include "wpapp.hpp" // include JS Debugger / CS Profiler enabler // this feature is enabled by default in the debug build only #include
using ::bb::cascades::Application; Q_DECL_EXPORT int main(int argc, char **argv) { // this is where the server is started etc Application app(argc, argv); WPApp *wpApp = new WPApp (&app); // we complete the transaction started in the app constructor and start the client event loop here return Application::exec(); // when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children) } wpapp. HPP
// Application with UI adaptability support template #ifndef WPApp_HPP_ #define WPApp_HPP_ #include
#include #include #include #include #include "library/StatData.h" using std::vector; using std::string; using namespace bb::cascades; namespace bb { namespace cascades { class Application; } } /*! * @brief Application pane object * *Use this object to create and init app UI, to create context objects, to register the new meta types etc. */ class WPApp : public QObject { Q_OBJECT public: WPApp(Application *); virtual ~WPApp(); Q_INVOKABLE void addStats(QString); Q_INVOKABLE void showAddScreen(); void addRemoveStat(string identifiers, bool add); private: vector mActiveStats; Page *mRootPane; NavigationPane *mNavPane; Application *mApp; }; #endif /* WPApp_HPP_ */ wpapp.cpp
// Application with UI adaptability support template #include "wpapp.hpp" #include
#include #include #include #include #include #include #include #include #include #include "Utilities.h" #include "connector/WConnector.h" #include "library/StatData.h" using std::string; using std::vector; using namespace bb::cascades; using namespace bb::system; WPApp::WPApp(Application *app) : QObject(app) { QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); qml->setContextProperty("app", this); //qml->setContextProperty("second", m_pane); if (!qml->hasErrors()) { mRootPane = qml->createRootObject (); mNavPane = new NavigationPane(); // set created root object as a scene //mNavPane->push(mRootPane); //Application::instance()->setScene(mNavPane); mApp = app; mApp->setScene(mRootPane); } } WPApp::~WPApp() { } void WPApp::addStations(QString text) { SystemToast *st = new SystemToast(Application::instance()); string sIdentifiers = text.toStdString(); NavigationPane *mNavPane = mNavPane->findChild ("navigationPane"); int ct = mNavPane->count(); mNavPane->pop(); st->setBody(text); st->setPosition(SystemUiPosition::MiddleCenter); st->show(); addRemoveStat(sIdentifiers, true); } void WPApp::showAddStat() { QmlDocument *qml = QmlDocument::create("asset:///AddScreen.qml").parent( this); qml->setContextProperty("app", this); Page *page = qml->createRootObject (); mNavPane->push(page); } void WPApp::addRemoveStat(string sIdentifiers, bool bAdd) { } Main.QML
// Application with UI adaptability support template import bb.cascades 1.0 import bb.system 1.0 NavigationPane { backButtonsVisible: true id: navigationPane objectName: navPane // create application UI page Page { actions: [ ActionItem { title: "Add" onTriggered: { //navigationPane.push(newPage); app.showAddScreen(); } ActionBar.placement: ActionBarPlacement.OnBar imageSource: "images/ic_add.png" }, ActionItem { title: "Refresh" onTriggered: app.initiateRequest() ActionBar.placement: ActionBarPlacement.OnBar imageSource: "images/ic_rotate.png" }, ActionItem { title: "Remove All" onTriggered: app.initiateRequest() imageSource: "images/ic_delete.png" }, ActionItem { title: "Settings" onTriggered: app.initiateRequest() imageSource: "images/ic_settings.png" } ] Container { layout: DockLayout { } AppBackground { // setup application background background: Color.Black verticalAlignment: VerticalAlignment.Fill horizontalAlignment: HorizontalAlignment.Fill } Container { horizontalAlignment: HorizontalAlignment.Fill Container { layoutProperties: StackLayoutProperties { spaceQuota: 1.0 } layout: DockLayout { } verticalAlignment: VerticalAlignment.Fill horizontalAlignment: HorizontalAlignment.Fill Container { property int padding: 10 layout: StackLayout { id: stationStacks // change layout direction according to current device orientation // this feature is disabled for 720x720 devices in current template // see: assets/720x720/AppOrientationHandler.qml orientation: (orientationHandler.orientation == UIOrientation.Portrait) ? LayoutOrientation.TopToBottom : LayoutOrientation.LeftToRight } // create 9-sliced frame for this container background: frame.imagePaint topPadding: padding bottomPadding: padding leftPadding: padding rightPadding: padding verticalAlignment: VerticalAlignment.Center horizontalAlignment: HorizontalAlignment.Center } } } attachedObjects: [ AppOrientationHandler { // custom orientation handler // the different handler is used for 720x720 in this template // to disable oriantation adaptability for this kind of devices id: orientationHandler } ] } attachedObjects: [ // Create the ComponentDefinition that represents the custom // component in myPage.qml ComponentDefinition { id: addStation source: "AddScreen.qml" } ] } // Page } // NavigationPane
AddScreen.qml
import bb.cascades 1.0 import bb.system 1.0 Page { actions: [ ActionItem { title: "Search" ActionBar.placement: ActionBarPlacement.OnBar imageSource: "images/ic_search.png" }, ActionItem { title: "Add" onTriggered: { app.addStat(identifierInput.text) } ActionBar.placement: ActionBarPlacement.OnBar imageSource: "images/ic_add.png" } ] titleBar: TitleBar { title: "Add Stats" appearance: TitleBarAppearance.Plain } Container { layout: StackLayout { orientation: LayoutOrientation.TopToBottom } background: Color.DarkGray Container { layout: StackLayout { orientation: LayoutOrientation.LeftToRight } Label { text: "
Identifiers:" textFormat: TextFormat.Html } TextField { id: identifierInput hintText: "XXX YYY" horizontalAlignment: HorizontalAlignment.Left verticalAlignment: VerticalAlignment.Top inputMode: TextFieldInputMode.Text /*onTextChanging: { app.mNewIdentifiers = text console.log("Idents " + app.mNewIdentifiers) }*/ } } Container { layout: StackLayout { orientation: LayoutOrientation.TopToBottom } Label { text: "" } Picker { id: favoritesPicker title: "Favorites" } } }// Container } // PageHello
Add quotes around objectName:objectName: "navigationPane.
Maybe you are looking for
-
Question on DVD recovery for Satellite A210 - 1 c 4
Hi all This is my first post so if I get anything wrong, I apologize. just bought my daughter A210 - 1 c 4It came with a recovery cd, I would like to know what I need to back up the vista partition aswell or the cd contains it all to go back to the f
-
Re: Tecra A4 - can I record something due S-video port?
Hello I have a s-video connector on my Tecra A4 laptop. I have it plugged into a TV decoder / recorder provided by my ISP, but I get nothing on my other than the windows desktop screen. I don't have a TV in the apartment where I have the internet con
-
How can I organize a default font for the incoming/outgoing emails, please?
Several e-mails come to me in the form of plain text in very small print. Usually, I use Tahoma10 and want all my emails, inside and out, using this font. If anyone can tell me how to activate it, I'll keep a note in the case of wishing to change at
-
Where can I find a free download of windows spider solitaire
I have windows XP, but have no spider solitaire.
-
EA6500 installed the V2 firmware on router V1
Just had an EA6500, had problems with the wireless signal dropped randomly. I went to the Linksys and updated webpage to update firmware v2 without realizing that I already have the most recent firmware for a V1 router. Now all I get is the everlasti