06-06-2012 03:45 AM
I am looking at ways of generating images at run-time. I have been informed that Cascades does not support user-defined fields (i.e., I would write a class implementing paint and layout logic). It was suggested that QPainter could be used to generate the image on a QImage and then convert the QImage to Image to be assigned to the image property of an ImageView.
In an attempt to do so, I have written code like this:
QImage image(QSize(100,100), QImage::Format_RGB32);
painter.fillRect(0, 0, 100, 100, Qt::white);
//Causes Segmentation Fault!
painter.drawText(0, 0, 100, 100, Qt::AlignCenter | Qt::AlignHCenter, str);
PixelBufferData pb(PixelBufferData::RGBX, 100, 100, 100, image.bits());
Unfortunately, this generates a Segmentation Fault when it invokes drawText. Googling around reveals that others encounter this in the Qt world when using QPainter in the absence of a QApplication object.
So my question is: Can QPainter be used in a Cascades application? If so, are any samples available? If not, what would be the best way to generate images on the fly (e.g., a field which shows a bar chart based on data, etc.)
Solved! Go to Solution.
06-07-2012 12:07 PM
First, you might want to read through http://supportforums.blackberry.com/t5/Cascades-De
There is no direct comparable to Canvas
QPainter is not fully supported.
I see you've already found PixelBufferData https://developer.blackberry.com/cascades/referenc
I'll play around with the flexibility of PixelBufferData.
In the meantime, have you discovered anything new?
06-07-2012 12:27 PM
06-07-2012 01:40 PM
I was referring to:
I haven't tried this myself yet, so if you know more about it and its applicability, please let us know.
06-07-2012 02:52 PM
Thanks for the confirmation that QPainter is a "dead end" and for the WebView suggestion.
Glad to see that the need for custom painting has already been voiced clearly in other threads.
In probably every other framework I've seen in the past, the ability to paint is the foundation on which control classes are written. Just out of curiosity, how do the Cascade control classes implement their painting?
06-07-2012 03:06 PM
I'm interested to hear about any successes with WebView.
I also am interested in how you fare if you pursue openGL, and PixmapBufferData.
As for internals, it's perhaps best to treat that as a black box. One of the goals is to ensure that graphics is always displayed in a timely fashion, so we can't assume the internals are simple or overly relevant for most of us.
Are you prepared to mark this thread closed by accepting a post as a solution, or is there more to explore here first?
06-08-2012 04:21 PM