0

I wanted to render a video from a webcam in the background of a qt quick application. I used this code from 5.1.1 documentation to render a test video:

    import QtQuick 2.0
    import QtMultimedia 5.0

    Item {
        MediaPlayer {
            id: mediaplayer
            source: "groovy_video.mp4"
        }

        VideoOutput {
            anchors: parent.fill
            source: mediaplayer
        }

        MouseArea {
            id: playArea
            anchors.fill: parent
            onPressed: mediaplayer.play();
        }
    }

I have no QtQuick experience and it is double frustrating if not even the example (unmodified) is working:

Invalid property assignment: "anchors" is a read-only property 
anchors: parent.fill

What is wrong?

dgrat
  • 2,214
  • 4
  • 24
  • 46
  • 1
    It's error with documentation, correct syntax are not "anchors: parent.fill", but "anchors.fill: parent" (like in MouseArea). Which page of documentation? For fix it – gbdivers Sep 26 '13 at 18:10
  • @Guillaume Belz here http://qt-project.org/doc/qt-5.0/qtmultimedia/qml-qtmultimedia5-mediaplayer.html – iMath Feb 26 '14 at 11:15

1 Answers1

0

This might fix it:

import QtQuick 2.0
import QtMultimedia 5.0

Item {
    height: video.implicitHeight // or video.height
    width: video.implicitWidth // or video.width
    MediaPlayer {
        id: mediaplayer
        source: "groovy_video.mp4"
    }

    VideoOutput {
        id: video
        source: mediaplayer
    }

    MouseArea {
        id: playArea
        anchors.fill: parent
        onPressed: mediaplayer.play();
    }
}
Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313