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

Posts: 41
Registered: ‎10-16-2012
My Device: Bold 9000
My Carrier: Telus

Make a gradient rectangle.

How can I make a gradient rectangle?  Do I need to import Qt Quick to make a simple gradient?  How do I import Qt Quick if I need to?

Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Re: Make a gradient rectangle.

[ Edited ]

You don't need to import QQuick.  You can use all the Q commands such as QPaint,  but you'll then just need to save the eventual QImage into an Image for Cascades to view.


Checkout this source code to get an idea of how do it:



This is what I use


//returns unmirroed image
static bb::cascades::Image fromQImage(const QImage &qImage) {
	bb::ImageData imageData(bb::PixelFormat::RGBA_Premultiplied, qImage.width(),

	unsigned char *dstLine = imageData.pixels();
	for (int y = 0; y < imageData.height(); y++) {
		unsigned char * dst = dstLine;
		for (int x = 0; x < imageData.width(); x++) {
			QRgb srcPixel = qImage.pixel(x, y);
			*dst++ = qRed(srcPixel);
			*dst++ = qGreen(srcPixel);
			*dst++ = qBlue(srcPixel);
			*dst++ = qAlpha(srcPixel);
		dstLine += imageData.bytesPerLine();

	return imageData;

 this might give you some ideas as well but they never updated it for Beta 3:


If you find my post helpful please "like" it and "accept as a solution"