Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
Posts: 35
Registered: ‎03-04-2013
My Device: 9850
My Carrier: telus
Accepted Solution

reuse actionitems for all you qml pages

Is there a way to do this within qml so I don't have to rewrite all the page actionbar actionitems for every page?

 

I supposed its doable in c++ but I prefer to use qml.

 

So if I have a large number of common page actionitems like Share, Contact Us, and About can I define it in one qml and make it available for every page.

 

 

 

Developer
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: reuse actionitems for all you qml pages

Make a base Page qml file where you define all the common actions. Every time you have a page that needs to use those actions, use that Page as your "superclass." 

 

BasePage.qml:

Page {
    actions: [
        ActionItem {
            id: action1
             ....
        }
    }
}

 

Page implementing BasePage.qml:

import "../folderContainingBasePageDotQml"

BasePage {
    // this page will contain action items defined in BasePage.qml
}

 

Contributor
Posts: 35
Registered: ‎03-04-2013
My Device: 9850
My Carrier: telus

Re: reuse actionitems for all you qml pages

thanks will give it a try.

Contributor
Posts: 35
Registered: ‎03-04-2013
My Device: 9850
My Carrier: telus

Re: reuse actionitems for all you qml pages

great this works thanks.

 

didn't know you can do this.

 

btw, found out this neat little trick.

 

 

You can create a javscript file like this 

 

settings.js

var maxcount = 10

var mincount = 1

 

 

and from any qml do

 

import "settings.js" as Settings

 

then anywhere in the qml we can acces your vars

 

labeltext.text = Setting.maxcount

labeltext.text = Setting.mincount

 

works with javascript functions as well if you have javascripts functions you want to make available everywhere quickly.