If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
Trusted Contributor
itcraps
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus
Accepted Solution

Drawing QString as Image

Hi, is I would like to have QString object drawn as Image and display it on a ImageView..

 

I have research about this on google and the suggestion was that to "Paint" the QString to Bitmap..

 

Any thoughts on this? Thank you

www.jackdevora.com
Please use plain text.
Developer
Zmey
Posts: 1,510
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Drawing QString as Image

Hi,

In Qt it's done by drawing text on QImage using QPainter. In Cascades this Qt method doesn't work because text drawing depends on some data from Qt's QApplication object which isn't created in Cascades project's main(). I've tried creating it, but it conflicts with Cascades Application class.

I don't think anyone managed to use both Qt and Cascades simultaneously, so no known solution for this exists yet.

An idea to try is to create QApplication & Application in different threads or processes, but I have yet to experiment with that.

Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Trusted Contributor
itcraps
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus

Re: Drawing QString as Image

Thanks for the reply, so does that mean, In cascades, the only way to draw some text on an Image is to use QPainter?
www.jackdevora.com
Please use plain text.
Developer
Zmey
Posts: 1,510
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Drawing QString as Image

Drawing text using QPainter does not work in Cascades at the moment and there are no known workarounds to make it work.

 

Native font support is not there as well. It's scheduled to appear in future releases:
https://developer.blackberry.com/cascades/download/roadmap/

 

Can anyone suggest a third-party lib for text rendering?


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Drawing QString as Image

If you just need to display text on top of an image, make the image the background of a container and place the label for the text inside the container. This is super easy.

 

Scott

Please use plain text.
Developer
bobdodd
Posts: 116
Registered: ‎10-31-2012
My Device: BB10 Dev Alpha B
My Carrier: -

Re: Drawing QString as Image

You could look at PngWriter, thats an open souce C++ PNG lib

 

http://pngwriter.sourceforge.net/

Please use plain text.
Trusted Contributor
itcraps
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus

Re: Drawing QString as Image

@superdirt okay, so after placing it in the container, how do we save it?

@bobdodd Does PNG writer supports text rendering?

Thanks for all the suggestions
www.jackdevora.com
Please use plain text.
Developer
bobdodd
Posts: 116
Registered: ‎10-31-2012
My Device: BB10 Dev Alpha B
My Carrier: -

Re: Drawing QString as Image


itcraps wrote:

@bobdodd Does PNG writer supports text rendering?

Thanks for all the suggestions

Yes it does, and  it supports loading True Type fonts

Please use plain text.
Trusted Contributor
itcraps
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
My Carrier: Telus

Re: Drawing QString as Image

Thanks a lot bobdodd!!!
www.jackdevora.com
Please use plain text.
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Drawing QString as Image

My method is not useful if you're looking to save in a png.
Please use plain text.