Search code examples
gradientblackberry-10blackberry-cascades

Drawing gradient on BlackBerry 10 (Cascades and C++)


Is there any way to draw a simple linear gradient in Cascades or/and C++? I've found an example using QtQuick library (https://developer.blackberry.com/cascades/reference/qmlreusablecomponents.html), but it doesn't work. Even the import of this library isn't recognized by Momentics


Solution

  • Unfortunately gradients are not possible to do that way in Cascades.

    I would recommend using an gradient image and ImagePaintDefinition. For example:

    Container {
        layout: DockLayout {
    
        }
        preferredHeight: constants.headerHeight
        minHeight: preferredHeight
        maxHeight: preferredHeight
    
        minWidth: constants.screenWidth
        background: back.imagePaint
    
        attachedObjects: [
            Constants {
                id: constants
            },
            ImagePaintDefinition {
                id: back
                imageSource: "asset:///images/header_solid.png"
                repeatPattern: RepeatPattern.X
            }
        ]
    }