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
Regular Contributor
Posts: 51
Registered: ‎04-24-2013
My Device: Z10
My Carrier: Telkomsel

Create function date time format in C++

How to craete a function to format a date in C++ and access in qml. I have a function to format date but in qml, every time i need it i should write the function. So i need to create in c++ and access in qml but always fail.

Thanks.

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Create function date time format in C++

you can write the function in your root qml and access it in all child elements, even other pages.

if you want to do it in c++ you could create a Q_INVOKABLE method in a QObject. See the developer pages for more information about connecting c++ to qml.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 115
Registered: ‎10-22-2012
My Device: Developer
My Carrier: Mobifone

Re: Create function date time format in C++

In addition, you could create Q_INVOKABLE or Q_SLOT method in QObject-derived object and set that object to a context property on your qml



Like my answer if it's helpful. Mark as answer if it help you solve the problem.
Regular Contributor
Posts: 51
Registered: ‎04-24-2013
My Device: Z10
My Carrier: Telkomsel

Re: Create function date time format in C++

Thanks for replying