Reload main.qml
Can someone tell me how I could reload the main.qml completely?
This is how it is created at startup
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); qml->setContextProperty("_app", this); // Create root object for the UI AbstractPane *root = qml->createRootObject(); // Set created root object as the application scene Application::instance()->setScene(root);
I want the old main.qml should be deleted and a new creation.
I'm not so good with c ++ so any help is welcome
Thanks in advance
You can call setScene with a different component.
the question is: why would you do that?
Usually, you can use a spreadsheet to display a deviation from the regular workflow.
Tags: BlackBerry Developers
Similar Questions
-
Can I use "If", "else" statement in main.qml?
Hello
What statement I use within the main.qml?
is there documentation for things and the statement can be used within the mian.qml (e.g. 'if', 'for', 'while')
Hello
Engine QML use a JavaScript interpreter.
that statement is bug in Qt 4.8, so it is better to avoid it or explicit use of braces {} in the case branches. Other than that, it is simply JavaScript.
Syntax information QML is located on the Web site of the project-qt:
http://Qt-project.org/doc/Qt-4.8/qdeclarativeintroduction.html
I suggest you browse the other articles there as well.
-
Accessing the context property of main.qml to a custom list in a file item separate qml
Hi all
Sorry if this is already covered somewhere.
I currently have an application with a list view in my main.qml. I put a context property for my class app c ++ to be "app" in my main.qml. My list uses a custom list item that is defined in a file separate qml. The custom list item has a popup menu. In this context menu, I want to call Q_INVOKABLE functions that are part of my class from the main application in C++. What is the best way to be able to do? Should I just set the context property on my file qml of list item custom like I do with my main.qml or is there a better way?
Thank you
I think that this has been repeated several times, but as it is not really intuitive:
a listitemcomponent lies in a different context, it cannot access the context property of the qml file.
You can use the reference to the listview to reach outside, see https://developer.blackberry.com/cascades/reference/bb__cascades__listview.html ListItem.view -
Hi all;
I wanted that my application runs in the background (Headless) but first encountered several problems, calculation are qml functions (in main.qml: updateUi() with call javascript *.js files), who should I call their headless part when the part of the user interface is closed by the user? Please help me if you have any solution.
Thank you very much.
identify what treatment you need for the game without head and migrate to c + c++ / Qt.
-
Can't push to the navigation of a component outside the main.qml pane
Here's some of my main.qml
Container { id: main_content attachedObjects: [ ComponentDefinition { id: listtodo source: "mainList.qml" } ] property variant listtodoObj onCreationCompleted: { listtodoObj = listtodo.createObject(); if (!listtodoObj) listtodoObj = listtodo.createObject(); listtodoObj.dataModel = Model.get(); main_content.add(listtodoObj); } }
I have not included of NavigationPane, but in the hand, I have a pane of navigation with the id "navigationPane.
Here's the part of my mainList.qml:
gestureHandlers: [ TapHandler { attachedObjects: ComponentDefinition { id: infoPage; source: "asset:///taskInfo.qml" } onTapped: { var page = infoPage.createObject(); navigationPage.push(page); } } ]
But I can't access navigationPane. In the console it says: "cannot find variable: navigationPage.
What can I do?
This should help:
http://supportforums.BlackBerry.com/T5/native-development-knowledge/how-to-access-QML-properties-fro... -
Separating the main.qml in .qml different files, is more pushed page
Hi all
My main.qml became very long (NavigationPane with a Page with a container with a label and ListView and a certain objects attached) and I started to break up. Before that, when I chose a line in the list, it pushed successfully to the details of the page. However, when I copy and pasted all within the Page to another qml file that I put in main.qml as object, it is more pushed the detail of the page. I can't for the life of understand me. I saw / experienced with numerous examples of applications where he worked (Battambang in particular), but cannot see a difference between my folders and those.
Here are the files, dismembered. When the PillListPage.qml content is copied in main.qml, everything works fine.
//main.qml// Grid view with detail project template import bb.cascades 1.0 //import bb.platform 1.0 import bb.system 1.0 import "stringConcatenation.js" as StringConcatenation NavigationPane { id: navigationPane //contains time label and grid list view firstPage: PillListPage { } onCreationCompleted: { // this slot is called when declarative scene is created // write post creation initialization here console.log("NavigationPane - onCreationCompleted()") // enable layout to adapt to the device rotation // don't forget to enable screen rotation in bar-bescriptor.xml (Application->Orientation->Auto-orient) OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All; } onPopTransitionEnded: { // Transition is done destroy the Page to free up memory page.destroy() } }
//PillListPage.qmlimport bb.cascades 1.0 Page { id: pgMain content: Container { id: rootContainer verticalAlignment: VerticalAlignment.Center horizontalAlignment: HorizontalAlignment.Center Label { id: timeLabel text: { var currentTime = Qt.formatDateTime(new Date(), "h:mm AP"); return currentTime; } } //Label //PillListView ListView { id: listView // set object name to let listView be discoverable from C++ objectName: "listView" layout: GridListLayout { verticalCellSpacing: 100 cellAspectRatio: 4.0 columnCount: 1 horizontalCellSpacing: 10.0 } listItemComponents: [ // define component which will represent list item GUI appearence ListItemComponent { type: "item" // list item GUI appearence component is defined in external MyListItem.qml file MyListItem { } } ] onTriggered: { // When an item is selected we push the detail Page in the chosenItem file attribute. var chosenItem = dataModel.data(indexPath); // Create the content page and push it on top to drill down to it. var contentpage = pillDetailPageDefinition.createObject(); // Set the content properties to reflect the selected image. contentpage.contentImageURL = chosenItem.thumbnail contentpage.contentName = chosenItem.name + ", " + chosenItem.mass // Push the content page to the navigation stack navigationPane.push(contentpage); } layoutProperties: StackLayoutProperties { spaceQuota: 1.0 } focusPolicy: FocusPolicy.Default } //end of pill list } //end root Container // Attached objects of the Main Content Page attachedObjects: [ ComponentDefinition { id: pillDetailPageDefinition source: "PillDetailPage.qml" } //ComponentDefinition ] }
Some superfluous code (user interface format stuff) has been removed. I did essentially the same thing with the grid list Basic project template. Help, please! My only guess is that perhaps he does not know which is the data model, once he is out of main.qml. Is there something in c ++ I have to do or something I should even in the QML?
There is no runtime error and the app loaded successfully, with the only problem being that when I click on a list item, there is no response/transition to the details page.
However, I found a solution of mine. I pushed my detail view using a function that is called in the onTriggered signal in the list. Copy the following code is a basic example of what I mean I did simply by separating the code of the project template "grid with details view:
//main.qml // Grid view with detail project template import bb.cascades 1.0 NavigationPane { id: navigationPane firstPage: MainPageContent {} attachedObjects: [ ComponentDefinition { id: secondPageDefinition source: "DetailPage.qml" } ] function setDetailItem(item) { // show detail page var page = secondPageDefinition.createObject(); page.text = item.text page.image = item.image navigationPane.push(page) } onCreationCompleted: { // this slot is called when declarative scene is created // write post creation initialization here console.log("NavigationPane - onCreationCompleted()") // enable layout to adapt to the device rotation // don't forget to enable screen rotation in bar-bescriptor.xml (Application->Orientation->Auto-orient) OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All; } }
//MainPageContent.qml import bb.cascades 1.0 Page { id: pgMain content: Container { ListView { id: listView // set object name to let listView to be discoverable from C++ objectName: "listView" layout: GridListLayout { } listItemComponents: [ // define component which will represent list item GUI appearence ListItemComponent { type: "item" // list item GUI appearence component is defined in external MyListItem.qml file MyListItem { } } ] onTriggered: { console.log("selected_index: " + indexPath) var curr_item = dataModel.data(indexPath) // show detail page for selected item setDetailItem(curr_item) } horizontalAlignment: HorizontalAlignment.Fill layoutProperties: StackLayoutProperties { spaceQuota: 1.0 } } } }
Since I saw your response until after that I had changed my code, I can't test, but it can work. Thanks for the help!
-
Hello
I want to call a function in main.cpp main.qml! Is it possible to do this?
Help me solve this problem!
Hi Paul24,
Please check below link
http://developer.BlackBerry.com/Cascades/documentation/dev/integrating_cpp_qml/index.html
-------------------------------------------------------------------------------
feel free to press the button like on the right side to thank the user who has helped you.
-
Connection signal of C++ with slot QML
Before ask you, I searched for answers to this question, but I have not found a satisfactory example.
I have set up a service network in C++ that performs queries to REST against a backend. An example query would be to download a given element, the id of the item.
Once the item is extracted, I emit a signal such as:
itemReceived(QString& itemId, QString& item);
My question is how can I wire this signal to the slot in a QML page so that the status of the answer? I tried to connect the signal on the Qml in C++ slot, as follows:
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); QObject::connect(this->networkingService, SIGNAL(itemReceived(QString&, QString&)), qml, SLOT(onItemReceived(QString&, QString&));
With a correspondent QML "slot" like this:
function onItemReceived(x, y) { console.log("*********************"); console.log("Item Received!"); console.log("*********************"); }
But it does not work. I also tried using the element of connection of the QtQuick lib, but this also fails.
Any help would be greatly appreciated. Even if he were to propose a better architecture for the "path of the cascades. Thank you!
In C++:
QmlDocument * qml = QmlDocument::create("asset:///main.qml").parent(this);
QML-> setContextProperty ("_app", this);In QML:
{Page}
onCreationCompleted: {}
_APP.itemReceived.connect (onItemReceived)
}function onItemReceived (x, y) {}
Console.log("***");
Console.log ("point received!");
Console.log("***");
}// ...
} -
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.
-
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
-
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.
-
Hello, I am very new to C++ / QML development (I'm familiar with JAVA).
I try the simplest thing, create a named factorial function that takes a parameter (hard-coded) which displays the result on the screen when the application starts and displays the screen. Here is my code, please explain what I'm doing wrong. I'm not clear how everything together "fits".
Thanks a lot for the help of anyones!
ApplicationUI.cpp
#include "applicationui.hpp".
#include
#include
#includeusing namespace bb::cascades;
ApplicationUI::ApplicationUI():
QObject()
{Create the scene of active main.qml, the parent document is defined
to make sure that the document is destroyed properly stopped down.
QmlDocument * qml = QmlDocument::create("asset:///main.qml").parent(this);Create the root for the UI object
AbstractPane * root = qml->() createRootObject;
root-> setProperty ("labelText", factorial (5)); ERROR HERE (factorial was not declared in this scope)Root object created together as the stage of the application
Application::instance()-> setScene (root);
}chain of factorial (long n)
{
long years = 1;
for (long I = 2; I have<= n;="" ++i)="">=>
years = years * i;
If (SNA< 0)="">
Returns - 1;
}
}
Return QString::number (years);
}Application.HPP
#ifndef ApplicationUI_HPP_
#define ApplicationUI_HPP_#include
class MyCppObject;
Class ApplicationUI: public QObject
{
Q_OBJECT
public:
ApplicationUI();Virtual ~ ApplicationUI() {}
String factorial (long n) () / /ERROR HERE ('string' is not a type, without return, based on non-void return)};
#endif / * ApplicationUI_HPP_ * /.
hand. QML
import bb.cascades 1.4
{Page}
property alias labelText: label.text
{Of container
{Label
ID: label
text: "Label".
}Button {}
objectName: 'button '.
text: "Button".
}
}
}the error message is "string does not name a type" because the string is not a type of data in c ++.
(and in java, it would be a String with a capital S)Use QString.
-
Function call QML from C++ by signal... it does not work
Hello.
Please help me because I'm stuck the last day three...
Well
In main.qml
onComplete() / / signal... .to in button click
{
closeProgressBar();
}
function closeProgressBar() / / allows to stop the progress as dwonlaoding data from the internet bar had finished.
{
progressIndicator.stop ();
}
Now in my file app.c
Q_SIGNALS:
Sub rollback();
in my app.hpp
Emit Rollback();
but he calling is not my onComplete method...
and I am unable to stop my progressabar
pls help me...
As I did today my plug-in...
I am wating for your reply eagerly...
the connect statement is not correct. to take
Login.Complete.Connect (closeProgressBar)I suggest to connect the signal in the onCreationCompleted of the component slot so that runs only once.
I also suggest that you use some console.log statements to see if the slot is called.
Furthermore, you mixed hpp and c (or CPP) in your messages.
-
SEO QML controls a level lower.
I always got arround without this requirement, but I'm curious to know how this is possible.
asset > Main.qml
asset > EditPage.qml
asset > controls > CustomListView.qml
asset > controls > MyItem.qml
Main.QML:
import "controls" Page { CustomListView: { ... } }
CustomListView.qml:
Container { ListView { id: myListView listItemComponents: [ ListItemComponent { MyItem {} } ] } }
MyItem.qml:
Container { id: Item verticalAlignment: VerticalAlignment.Center horizontalAlignment: HorizontalAlignment.Center Label { text: ListItemData.title } contextActions: [ ActionSet { title: ListItemData.title ActionItem { title: Edit onTriggered: { editSheet.Open(); } attachedObjects:[ EditPage { id: editSheet } ] } } ] }
EditPage control cannot be resolved because it is at a level lower than MyItem. Is it possible to reference a control / print this page which has lower visibility? How can this be accomplished?
try adding
import "../"
to your MyItem.qml
-
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
Maybe you are looking for
-
Satellite L650 (PSK1EA) new installation - how?
Hello my hard drive in the recently broken L650 (PSK1EA).I intend to buy a new one and replace only snag is that I never backed up my old one. I know I have to buy windows again, but what other things do I need.where can I get and when I install (bef
-
Satellite L755-18F - no free space on partition D
I'll try that in English, sorry about that ;) A few weeks ago, I use my toshiba L755-18E recovery tool. Everything went well, but suddenly, the 'Data D:' partition was all memory used (4,90 MB available 232 GB). I'll try to upload the photo, I don't
-
How to sync the button in the mainVI with a Subvi round?
(1) son? (2) global variable? ================ I want to stop some programs in Subvi execution by pressing the button in the mainVI. How to connect the button in the mainVI with a Subvi round? (1) son? It does work if I connect the button with the cy
-
my hp does not illuminate
-
How can I change the duration of an MP3 file I downloaded? For example, I have a song that 1.5 last minute, but I want to only keep the 21 seconds. How can I culture there?