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
Highlighted
Developer
Posts: 93
Registered: ‎10-29-2012
My Device: Z10
My Carrier: Various
Accepted Solution

Custom drawn control

Is there an example on how to create a custom drawn control? I could not find anything.

 

The only thing I could find was on creating custom QML componenets wich are really just composit controls with no custom drawing. that's located here

 

What we need is a custom drawn control. I could not find any property of the "CustomControl" class that would allow me to draw directly on the surface of the control. 

Normally - one can draw using various drawing functions, put pieces of images, fill areas etc... 

 

Is this possible and if so - does anyone have more information?

 

Thanks.

 

Developer
Posts: 93
Registered: ‎10-29-2012
My Device: Z10
My Carrier: Various

Re: Custom drawn control

I Looked everywhere for any kind of drawing functions that allow me to draw onto the CustoControl surface, but could not find anything. 

 

Can anyone confirm if this is possible at all with casscades? It would definitely be a show stopper here.

Developer
Posts: 407
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: Custom drawn control

Developer
Posts: 93
Registered: ‎10-29-2012
My Device: Z10
My Carrier: Various

Re: Custom drawn control

No - that's not it. This is still using just ImageViews with rotations to create a custom control.

 

Is there a way to draw onto the control using a set of drawing functions to draw lines circles, then fill the etc?

 

Developer
Posts: 93
Registered: ‎10-29-2012
My Device: Z10
My Carrier: Various

Re: Custom drawn control

It seems that there is a way to do this after all. It is a bit convoluted and not documented well, but it can be done.

 

In short - one can use QImage to paint anything using the QPainter and then use the QImage to create the Image that can be used in ImageView for example.

 

QImage is not on the list of classes in cascades Qt section, but I did find the following post that started me in the right direction.

http://supportforums.blackberry.com/t5/Cascades-Development-Knowledge/Using-QImage-and-QPainter-to-P...

 

You cannot use the above sample as is, however. The sample code has been removed from the GitHub. The reason is mostl ikely the PixelBufferData class which has been removed in the latest release.

 

You can use the new ImageData class though. I have tested this and could do anything I wanted using QPainter.

 

An example on how to get the ImageData from QImage is within the help for the ImageData class found here

 

Having the ability to use QImage and other Qt classes is GREAT - specially for people like me who are coming from the Qt world. I think cascades support for Qt should be as broad as possible. I would have prefered QtCreator instead of eclipse as the first class ide for cascades, but that's a topic for another day...

 

I hope this helps someone solve the similar issue.

 


If this post helped you - please like it. If it answered your question - please accept as a solution - Thanks.