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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
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
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

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
Developer
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
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

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
Developer
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

Developer
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/

Developer
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
Developer
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

Highlighted
Developer
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
Developer
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.