2018年5月1日

Transition

モジュール

QtQuick 2.0

クラス継承

QQuickTransition → QObject

プロパティー

animations: list<Animation> = [] readonly default deferred
enabled: bool = true
from: string = "*"
reversible: bool = false
running: bool = false readonly
to: string = "*"

シグナル

enabledChanged()
fromChanged()
reversibleChanged()
runningChanged()
toChanged()

説明


プロパティーの説明

animations: list<Animation>

enabled: bool

from: string

reversible: bool

running: bool

to: string

問題


Transition のリファレンスに animations プロパティーが遅延プロパティーであることが書かれていない。

参考情報

State

モジュール

QtQuick 2.0

クラス継承

QQuickState → QObject

プロパティー

changes: list<QQuickStateOperation> = [] readonly default deferred
extend: string = QString()
name: string = QString()
when: QQmlBinding* = nullptr

シグナル

completed()

説明


プロパティーの説明

changes: list<QQuickStateOperation>

カレントステートになったときに変更するプロパティーと実行スクリプトを指定する。QQuickStateOperation を継承しているのは以下のクラス。
QQuickParentChange
QQuickAnchorChanges
QQuickPropertyChanges
QQuickStateChangeScript
従って AnchorChanges と ParentChange、PropertyChanges、StateChangeScript を要素とするリストが設定できる。

extend: string

name: string

when: QQmlBinding*

シグナルの説明

completed()

問題


State のリファレンスの changes プロパティーは型表記が存在しないものになっている。また何を設定できるかが明確に記載されていない。遅延プロパティーであることも書かれていない。

参考情報

console

ログ

console.debug(...)
console.error(...)
console.info(...)
console.log(...) (console.debug() と同じ)
console.warn(...)
print(...) (console.debug() と同じ)

アサーション

console.assert(式, 説明文字列)

タイマー

console.time(識別文字列)
console.timeEnd(識別文字列)

トレース

console.trace()

カウント

console.count(説明文字列)

プロファイリング

console.profile()
console.profileEnd()

例外

console.exception(式...)

問題


Console API のリファレンスに print() が記載されていない。

参考情報

Console API

AnimatedImage

モジュール

QtQuick 2.11

クラス継承

QQuickAnimatedImage → QQuickImage → QQuickImageBase (internal) → QQuickImplicitSizeIte (internal) → QQuickItemQObject

プロパティー

playing: bool = true
paused: bool = false
currentFrame: int = 0
frameCount: int = 0 readonly
speed: real = 1

sourceSize: size = Qt.size(0, 0) readonly override

シグナル

frameChanged()
frameCountChanged()
pausedChanged()
playingChanged()
speedChanged()

void sourceSizeChanged() override

説明


プロパティーの説明

playing: bool

paused: bool

currentFrame: int

frameCount: int

speed: real

sourceSize: size

シグナルの説明

sourceSizeChanged()

注意


sourceSize プロパティーはオーバーライドされて読み込み専用になっている。

問題


AnimatedImage のリファレンスにはオーバーライドされた sourceSize プロパティーが記載されていない。

参考情報

anchored.qml

anchored.qml:

import QtQuick 2.10
import QtQuick.Window 2.10

Window {
    id: window

    visible: true

    minimumWidth: 300
    minimumHeight: 300

    Rectangle {
        id: movingRect

        x: 10; y: 10
        width: 150; height: 150

        color: "red"

        MouseArea {
            anchors.fill: parent

            onClicked: {
                if (movingRect.state === "") {
                    movingRect.state = "anchored";
                } else {
                    movingRect.state = "";
                }
            }
        }

        states: State {
            name: "anchored"

            AnchorChanges {
                target: movingRect
                anchors {
                    right: contentItem.right
                    bottom: contentItem.bottom
                }
            }

            PropertyChanges {
                target: movingRect
                anchors {
                    rightMargin: 10
                    bottomMargin: 10
                }
            }
        }

        transitions: Transition {
            AnchorAnimation {
                duration: 1000
            }
        }
    }
}
Rectangle をクリックすると Rectangle にアンカーを付けて右下に配置し、もう一度クリックするとアンカーを削除している。AnchorChanges ではマージン指定をできないので PropertyChanges で指定している。

AnchorChanges

モジュール

QtQuick 2.0

クラス継承

QQuickAnchorChanges → QQuickStateOperation (internal) → QObject

プロパティー

anchors: QQuickAnchorSet* = QQuickAnchorSet(nullptr) readonly constant
anchors.left: QQmlScriptString = ""
anchors.right: QQmlScriptString = ""
anchors.horizontalCenter: QQmlScriptString = ""
anchors.top: QQmlScriptString = ""
anchors.bottom: QQmlScriptString = ""
anchors.verticalCenter: QQmlScriptString = ""
anchors.baseline: QQmlScriptString = ""
target: Item = null

説明


State 内で用いてアンカーを変更する。アニメーション効果を付けるには Transition 内で AnchorAnimation を使う。

サンプルコードanchored.qml を参照。

プロパティーの説明

anchors: QQuickAnchorSet*

anchors.left: QQmlScriptString

anchors.right: QQmlScriptString

anchors.horizontalCenter: QQmlScriptString

anchors.top: QQmlScriptString

anchors.bottom: QQmlScriptString

anchors.verticalCenter: QQmlScriptString

anchors.baseline: QQmlScriptString

target: Item

注意


AnchorChanges の anchors の型は Item の anchors の型とは異なっている。マージンなどがない。

問題


anchors.left などの設定を item.Left や item.center のように書き間違えてもその値が udefined なので警告もされずに実行されてしまう。

参考情報