0

このようなラベルのコンテナがあります...しかし、ラベルの値が負の場合は、赤色を追加する必要があります。それ以外の場合は緑色を追加します。QmlのBB 10カスケードでそれを行うにはどうすればよいですか。

Container {
    leftPadding: 15.0
    rightPadding: 15.0
    layout: StackLayout {
        orientation: LayoutOrientation.LeftToRight
    }
    topPadding: 20.0

    Label {
        id: symbol
        text: ListItemData.Symbol_En

        // Text Style and size etc
        textStyle.base: SystemDefaults.TextStyles.SubtitleText
        textStyle.fontSizeValue: 30.0
        layoutProperties: StackLayoutProperties {
            spaceQuota: 4
        }
        verticalAlignment: VerticalAlignment.Center
        horizontalAlignment: HorizontalAlignment.Center

    }
    Label {
        id: change
        text: ListItemData.PerChange
        textStyle.base: SystemDefaults.TextStyles.SubtitleText
        textStyle.fontSizeValue: 30.0
        layoutProperties: StackLayoutProperties {
            spaceQuota: 2
        }
        verticalAlignment: VerticalAlignment.Center
        horizontalAlignment: HorizontalAlignment.Center

    }
    Label {
        id: ltp
        text: ListItemData.LTP
        textStyle.base: SystemDefaults.TextStyles.SubtitleText
        textStyle.fontSizeValue: 30.0
        layoutProperties: StackLayoutProperties {
            spaceQuota: 1
        }
        verticalAlignment: VerticalAlignment.Center
        horizontalAlignment: HorizontalAlignment.Center

    }
    Label {
        id: highValue
        text: ListItemData.High
        textStyle.base: SystemDefaults.TextStyles.SubtitleText
        textStyle.fontSizeValue: 30.0
        layoutProperties: StackLayoutProperties {
            spaceQuota: 1
        }
        verticalAlignment: VerticalAlignment.Center
        horizontalAlignment: HorizontalAlignment.Center

    }
    Label {
        id: lowValue
        text: ListItemData.Low
        textStyle.base: SystemDefaults.TextStyles.SubtitleText
        textStyle.fontSizeValue: 30.0
        layoutProperties: StackLayoutProperties {
            spaceQuota: 1
        }
        verticalAlignment: VerticalAlignment.Center
        horizontalAlignment: HorizontalAlignment.Center

    }
4

1 に答える 1

0

このようなものはどうですか(問題のラベルのみ):

Label {
        id: highValue
        text: ListItemData.High
        textStyle.color: ListItemData.High.indexOf("-") < 0 ? Color.Green : Color.Red 
        textStyle.base: SystemDefaults.TextStyles.SubtitleText
        textStyle.fontSizeValue: 30.0
        layoutProperties: StackLayoutProperties {
            spaceQuota: 1
        }
        verticalAlignment: VerticalAlignment.Center
        horizontalAlignment: HorizontalAlignment.Center
    }
于 2013-08-30T07:38:46.447 に答える