2018年5月19日

PropertyAction

モジュール

QtQuick 2.0

クラス継承

QQuickPropertyAction → QQuickAbstractAnimation (internal) → QObject

プロパティー

exclude: list<QtObject> = [] readonly
properties: string = ""
property: string = ""
target: QtObject = null
targets: list<QtObject> = [] readonly
value: QVariant = undefined

シグナル

targetChanged()
propertiesChanged(string)
propertyChanged()
valueChanged(QVariant)

説明


プロパティーの説明

exclude: list<QtObject>

properties: string

property: string

target: QtObject

targets: list<QtObject>

value: QVariant

参考情報

2018年5月9日

WorkerScript

モジュール

QtQuick 2.0

クラス継承

QQuickWorkerScript → QObject

プロパティー

source: url = QUrl()

シグナル

message(QQmlV4Handle messageObject)

sourceChanged()

スロット

void sendMessage(QQmlV4Function*)

説明


プロパティーの説明

source: url

シグナルの説明

message(QQmlV4Handle messageObject)

スロットの説明

void sendMessage(QQmlV4Function*)

参考情報

2018年5月8日

ScriptAction

モジュール

QtQuick 2.0

クラス継承

QQuickScriptAction → QQuickAbstractAnimation (internal) → QObject

プロパティー

script: QQmlScriptString = QQmlScriptString()
scriptName: QString = ""

説明


プロパティーの説明

script: QQmlScriptString

scriptName: QString

参考情報

2018年5月7日

DelegateModelGroup

モジュール

QtQml.Models 2.1

クラス継承

QQmlDelegateModelGroup → QObject

プロパティー

count: int = 0 readonly
name: QString = ""
includeByDefault: bool = false

シグナル

changed(QQmlV4Handle removed, QQmlV4Handle inserted)
countChanged()
defaultIncludeChanged()
nameChanged()

メソッド

QQmlV4Handle get(int index)

スロット

void addGroups(QQmlV4Function*)
void create(QQmlV4Function*)
void insert(QQmlV4Function*)
void move(QQmlV4Function*)
void resolve(QQmlV4Function*)
void remove(QQmlV4Function*)
void removeGroups(QQmlV4Function*)
void setGroups(QQmlV4Function*)

説明


プロパティーの説明

count: int

name: QString

includeByDefault: bool

シグナルの説明

changed(QQmlV4Handle removed, QQmlV4Handle inserted)


defaultIncludeChanged()

includeByDefault プロパティーの変更通知シグナル。

メソッドの説明

QQmlV4Handle get(int index)

スロットの説明

void addGroups(QQmlV4Function*)

void create(QQmlV4Function*)

void insert(QQmlV4Function*)

void move(QQmlV4Function*)

void resolve(QQmlV4Function*)

void remove(QQmlV4Function*)

void removeGroups(QQmlV4Function*)

void setGroups(QQmlV4Function*)

注意


includeByDefault プロパティーの変更通知シグナルが defaultIncludeChanged() となっていて命名規則と異なっている。

参考情報

2018年5月6日

ParentChange

モジュール

QtQuick 2.0

クラス継承

QQuickParentChange → QQuickStateOperation (internal) → QObject

プロパティー

target: Item = null
parent: Item = null
x: QQmlScriptString = ""
y: QQmlScriptString = ""
width: QQmlScriptString = ""
height: QQmlScriptString = ""
scale: QQmlScriptString = ""
rotation: QQmlScriptString = ""

説明


target に指定したビジュアルオブジェクトの parent を変更する。

x、y、width、height、scale、rotation で指定しないものがあるとき、parent を変更するビジュアルオブジェクトのそれらの値は見掛けをそのままにするような parent 変更先ビジュアルオブジェクト座標系での値に変更される。つまり、x と y の座標値は parent 変更先ビジュアルオブジェクトから見た座標値になり、スケールは逆数に、角度は逆向きになって、parent を変更する前の見掛けを保つように変更される。

x、y、width、height、scale、rotation のいずれかあるいは複数に parent 変更先ビジュアルオブジェクトでのプロパティー値を設定すると ParentAnimation でアニメーション効果を付けられる。

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

プロパティーの説明

target: Item

parent を変更するビジュアルオブジェクト。

parent: Item

parent 変更先ビジュアルオブジェクト。

x: QQmlScriptString

parent 変更先ビジュアルオブジェクトでの x 座標値を指定する。

y: QQmlScriptString

parent 変更先ビジュアルオブジェクトでの y 座標値を指定する。

width: QQmlScriptString

parent 変更後の幅を指定する。

height: QQmlScriptString

parent 変更後の高さを指定する。

scale: QQmlScriptString

parent 変更後のスケールを指定する。

rotation: QQmlScriptString

parent 変更後の角度を指定する。

問題


兄弟関係にある複数ビジュアルオブジェクトの parent を変更しようとすると正しく動作しない場合がある。

参考情報

ParentAnimation

モジュール

QtQuick 2.0

クラス継承

QQuickParentAnimation →  QQuickAnimationGroup (internal) → QQuickAbstractAnimation (internal) → QObject

プロパティー

target: Item = null
newParent: Item = null
via: Item = null

シグナル

targetChanged()
newParentChanged()
viaChanged()

説明


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


プロパティーの説明

target: Item

newParent: Item

via: Item

parent 変更先のビジュアルオブジェクトが parent 変更元のビジュアルオブジェクトよりも描画順序が先の場合や parent 変更先と変更元のいずれかのビジュアルオブジェクトの clip が true に設定されている場合に、clip が false に設定されているビジュアルオブジェクトを指定して parent を変えるビジュアルオブジェクトが隠れないようにする。

問題


ParentAnimation のリファレンスには親ビジュアルオブジェクトの clip が true のときの via 使用について書かれているがビジュアルオブジェクトの描画順序のために via が必要なことが書かれていない。

参考情報

2018年5月5日

switchparent.qml

switchparent.qml:

import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.Layouts 1.3

Window {
    id: window

    visible: true

    minimumWidth: 300
    minimumHeight: 300

    RowLayout {
        id: topLayout

        anchors.fill: parent
        anchors.margins: spacing

        Rectangle {
            id: leftRect

            Layout.fillWidth: true
            Layout.fillHeight: true

            objectName: "leftRect"
            color: "red"

            Rectangle {
                id: innerRect

                x: 10; y: 10
                width: (minimumWidth - 3*topLayout.spacing)/2 - 2*10
                height: width

                color: "blue"

                Text {
                    anchors.centerIn: parent

                    text: "%1\n%2, %3\n%4x%5".arg(innerRect.parent.objectName)
                                             .arg(parent.x).arg(parent.y)
                                             .arg(parent.width).arg(parent.height)
                    color: "white"
                }
            }
        }

        Rectangle {
            id: rightRect

            Layout.fillWidth: true
            Layout.fillHeight: true

            objectName: "rightRect"
            color: "green"
        }
    }

    contentItem.states: State {
        name: "switchToRight"

        ParentChange {
            target: innerRect
            parent: rightRect
            x: rightRect.width - innerRect.width - 10
            y: rightRect.height - innerRect.height - 10
        }

        PropertyChanges {
            target: innerRect
            color: "darkblue"
        }
    }

    contentItem.transitions: Transition {
        ParentAnimation {
            via: contentItem

            NumberAnimation {
                properties: "x, y"
                duration: 3000
            }

            ColorAnimation {
                duration: 3000
            }
        }
    }

    MouseArea {
        anchors.fill: parent

        onClicked: {
            if (contentItem.state === "") {
                contentItem.state = "switchToRight";
            } else {
                contentItem.state = "";
            }
        }
    }
}
ウィンドウをクリックすると青い Rectangle の parent を右側の Rectangle に変更し右下に配置する。もう一度クリックすると parent を元に戻している。ParentAnimation 内の 2 つのアニメーションは並列に動作する。ParentAnimation で via を指定しないと青い Rectangle が右側から左側に移動するときに右側の Rectangle の裏に隠れてしまう。これはアニメーション開始時に青い Rectangle の parent が左側の Rectangle に変わることと、左側の Rectangle の parent 設定が右側の Rectangle の parent 設定よりも先に行われているので左側の Rectangle が右側の Rectangle の下に描画されるためである。

2018年5月4日

Behavior

モジュール

QtQuick 2.0

クラス継承

QQuickBehavior → QtObject

プロパティー

animation: Animation = null default deferred
enabled: bool = true

シグナル

enabledChanged()

説明


プロパティーの説明

animation: Animation

enabled: bool

問題


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

参考情報

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 なので警告もされずに実行されてしまう。

参考情報