paxdiablo
paxdiablo

Reputation: 882028

Cannot use QtMultimedia in Qt Creator (Windows)

I am using the designer within QtCreater to attempt to create a proof-of-concept video stream player with QML. It's using Quick Controls rather than widgets as it will need to run on a device with no widgets available.

I've successfully put a one-pixel red border on the screen edges with an empty rectangle inside it (rectangles withing column layout within row layout) as a simple start. This runs both under Windows and on the device I intend to deploy to.

However, I want to replace the empty rectangle with a video player control and I'm having trouble figuring out how to do that, initially for Windows.

I've added multimedia to the original qml quick that my QT variable was set to in ProjName.pro file, and I've run qmake from the menu to ensure it's been actioned.

However, when I then use QtCreator to try and import the module while editing the main form in the designer, I can see nothing containing the word "multimedia" at all. All I see is:

Qt.labs.calendar 1.0
Qt.labs.controls 1.0
Qt.labs.controls.material 1.0
Qt.labs.controls.universal 1.0
Qt.labs.folderlistmodel 2.1
Qt.labs.settings 1.0
Qt.labs.templates 1.0
QtCanvas3D 1.1
QtGraphicalEffects.private 1.0
QtPositioning 5.6
QtQuick.Controls 1.5
QtQuick.Extras 1.4
QtQuick.LocalStorage 2.0
QtQuick.Window 2.2
QtQuick.XmlListModel 2.0
QtSensors 5.6
QtTest 1.1
QtWebSockets 1.0
QtWebView 1.1

I can manually edit the MainForm.ui.qml file and insert import QtMultimedia 5.6 into it but, when the designer comes back up, it has an alert next to the top level control with the help text:

found not working imports:
    file:///C:/path-to/MainForm.ui.qml:2 module "QtMultimedia"
    is not installed

This is all with QtCreator 4.0.1 as downloaded from Qt's site about a month ago, and we're using Qt 5.6.1 on both Windows and the target platform.

All the solutions I found on the net seem to indicate that the import is all that's needed but this appears not to be the case here.

Any ideas what I'm doing wrong, or what is the process for getting one of the QtMultimedia controls running within a QML app?

Upvotes: 0

Views: 1636

Answers (1)

Mitch
Mitch

Reputation: 24406

Apparently this is intentional. From what I've been told, the best approach is to instead create a separate component (QML file, via the text editor) that itself imports the multimedia types. That can then be used in the designer. For example, if you create VideoItem.qml with the following contents, you can use that in the designer:

import QtQuick 2.0
import QtMultimedia 5.5

Rectangle {
    width : 200
    height : 200
    color: "black"

    Video {
        id: video
        source: "video.avi"
        anchors.fill: parent
    }
}

Upvotes: 2

Related Questions