2

Blackberry 10 Cascades サンプル コードをダウンロードし、QML の学習に取り組んでいます。ただし、コードの周りに//! [0]//! [1]、 などのコメント//! [2]が散らばっていますが、それらのコメントの意味に関するドキュメントはありません。

これが私が話していることを示すサンプルです(金属探知機のサンプル):

import bb.cascades 1.0
import QtMobility.sensors 1.2
import bb.vibrationController 1.0

Container {
    leftPadding: 20
    rightPadding: 20
    bottomPadding: 20

    //! [0]
    attachedObjects: [
        Magnetometer {
            id: metalfinder

            // Create various variables to hold values from magnetometer reading
            property double baseline: 0
            property double magnitude: 0
            property double intensity: 0
            property double x: 0
            property double y: 0
            property double z: 0

            // Turn on the sensor
            active: true

            // Keep the sensor active when the app isn't visible or the screen is off (requires app permission in bar-descriptor)
            alwaysOn: true

            onReadingChanged: { // Called when a magnetometer reading is available
                magnitude = Math.sqrt(reading.x * reading.x + reading.y * reading.y + reading.z * reading.z);
                if (0 == baseline) {
                    baseline = magnitude;
                }
                intensity = ((magnitude - baseline) / magnitude) * 100;
                if (intensity > 0) {
                    vib.start(intensity, 100);
                }
                x = reading.x;
                y = reading.y;
                z = reading.z;
            }
        },

        VibrationController {
            id: vib
        }
    ]
    //! [0]

    layout: DockLayout {}

    //! [1]
    Button {
        horizontalAlignment: HorizontalAlignment.Center
        verticalAlignment: VerticalAlignment.Center

        text: qsTr("Zero Out Metal Finder")

        onClicked: {
            metalfinder.baseline = metalfinder.magnitude
        }
    }
    //! [1]

    Container {
        horizontalAlignment: HorizontalAlignment.Fill
        verticalAlignment: VerticalAlignment.Bottom

        layout: StackLayout {
            orientation: LayoutOrientation.LeftToRight
        }

        //! [2]
        Label {
            layoutProperties: StackLayoutProperties {
                spaceQuota: 1
            }

            text: qsTr("X: %1").arg((metalfinder.x * 1000000).toPrecision(5))
            textStyle {
                base: SystemDefaults.TextStyles.BodyText
                color: Color.White
            }
        }
        //! [2]

        Label {
            layoutProperties: StackLayoutProperties {
                spaceQuota: 1
            }

            text: qsTr("Y: %1").arg((metalfinder.y * 1000000).toPrecision(5))
            textStyle {
                base: SystemDefaults.TextStyles.BodyText
                color: Color.White
            }
        }

        Label {
            layoutProperties: StackLayoutProperties {
                spaceQuota: 1
            }

            text: qsTr("Z: %1").arg((metalfinder.z * 1000000).toPrecision(5))

            textStyle {
                base: SystemDefaults.TextStyles.BodyText
                color: Color.White
            }
        }

        Label {
            layoutProperties: StackLayoutProperties {
                spaceQuota: 1
            }

            text: qsTr("Mag: %1").arg((metalfinder.magnitude * 1000000).toPrecision(5))

            textStyle {
                base: SystemDefaults.TextStyles.BodyText
                color: Color.White
            }
        }
    }
}
4

1 に答える 1

3

ファイルの1つをチェックすると、次のqdocような行が表示されます

\snippet SensorDemo/assets/motionalarm.qml 1

ある種のドキュメントのハイパーリンクだと思います。

参考までに QDOC - \snippet

于 2013-05-18T11:37:17.827 に答える