Qt 在图像和相机之间切换视图时qml的奇怪行为

Qt 在图像和相机之间切换视图时qml的奇怪行为,qt,qml,Qt,Qml,试图在相机和图像之间切换视图,但结果非常奇怪 工具栏测试.qml import QtQuick 2.0 Item{ id:root height: 800; width: 144 signal fullScreen() signal camera() signal photo() Column{ id: toolBarColumn anchors.fill: root spacing: 10

试图在相机和图像之间切换视图,但结果非常奇怪

工具栏测试.qml

import QtQuick 2.0

Item{
    id:root
    height: 800; width: 144

    signal fullScreen()
    signal camera()
    signal photo()

    Column{
        id: toolBarColumn

        anchors.fill: root
        spacing: 10

        Rectangle{

            width: 144
            height: 70
            color: "blue"

            Text{
                text: "fullScreen"
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    fullScreen()
                }
            }
        }

        Rectangle{

            width: 144
            height: 70
            color: "blue"

            Text{
                text: "camera"
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    camera()
                }
            }
        }

        Rectangle{

            width: 144
            height: 70
            color: "blue"

            Text{
                text: "photo"
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    photo()
                }
            }
        }
    }
}
光测试

import QtQuick 2.0
import QtMultimedia 5.0


Rectangle{
    id: root

    width: 480
    height: 320
    color: "black"
    state: "PHOTO"

    property alias source: largeImage.source

    property var theID: largeImage

    QtObject{
        id: param

        property var theID: largeImage
    }

    Image{
        id : largeImage
        anchors.fill: parent
        cache: false
        fillMode: Image.PreserveAspectFit
        smooth: true
    }

    Camera{
        id: camera
    }

    VideoOutput {
        id: videoOutput

        anchors.fill: parent
        source: camera
    }

    states:[
        State {
            name: "PHOTO"
            StateChangeScript{
                script:{
                    camera.stop()
                    param.theID = largeImage
                }
            }

            PropertyChanges { target: largeImage; opacity: 1}
            PropertyChanges { target: videoOutput; opacity: 0}
        },
        State {
            name: "CAMERA"
            StateChangeScript{
                script:{
                    camera.captureMode = Camera.CaptureStillImage
                    camera.start()
                    param.theID = videoOutput
                }
            }

            PropertyChanges {target: largeImage; opacity: 0}
            PropertyChanges { target: videoOutput; opacity: 1}
        }
    ]
}
main.qml

import QtQuick 2.0

Rectangle {
    id: root

    width: 800
    height: 480

    QtObject{
        id: param

        property string previousFullScreenState
    }

    ToolBarTest{
        id: toolBarTest

        onFullScreen: {
            param.previousFullScreenState = root.state
            root.state = "FULLSCREEN"
        }

        onPhoto: {
            root.state = "PHOTO"
        }

        onCamera: {
            root.state = "CAMERA"
        }
    }

    PhotoTest{
        id: photoTest

        anchors.left: toolBarTest.right
        width: parent.width - toolBarTest.width

        source: "/Users/yyyy/Downloads/1359170070532.jpg"

        MouseArea{
            anchors.fill: parent

            onClicked: {
                if(root.state == "FULLSCREEN"){
                    root.state = param.previousFullScreenState
                }
            }
        }
    }

    states: [
        State {
            name: "PHOTO"

            PropertyChanges { target: photoTest; state: "PHOTO"}
            PropertyChanges { target: toolBarTest; width: 144}
        },
        State {
            name: "CAMERA"

            PropertyChanges { target: photoTest; state: "CAMERA"}
            PropertyChanges { target: toolBarTest; width: 144}
        },
        State {
            name: "FULLSCREEN"

            PropertyChanges { target: toolBarTest; width: 0}
        }
    ]
}
一旦状态为“摄像机”,我点击“全屏”按钮 photoTest.qml不显示相机的全尺寸,但 照片的全尺寸,发生了什么?我会犯什么样的错误

Qt版本:5.1贝塔 操作系统:mac osx 10.8.3
编译器:clang3.2

我显式地将main.qml中的“全屏”状态指定为

State {
            name: "FULLSCREEN"

            PropertyChanges { target: photoTest; state: param.fullScreenPreviousState == "PHOTO" ? "PHOTO" : "CAMERA"} //new conditon
            PropertyChanges { target: toolBarTest; width: 0}
        }
当改变状态时,我们必须明确指定不同组件的所有条件