Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
-
b2qt 5.1 for raspberrypi0
Qt version 5.12.0
Description
Error type: Unknown method return type: QMediaPlaylist*
It happens when passing QMediaPlaylist* from C++ to QML.
The code is compose by a playlistModel that load automatically a playlist vector according to the folder found in the system. In QML the user select the playlist which gets loaded in MediaPlayer.
In QML the playlist model is shown with a pathView and one selected, its index is passed to a MediaPlayer as follow:
_import QtQuick 2.6
import QtQuick.Controls 2.0
import QtMultimedia 5.9
import "."
import "QUItMeterComponent"
import "../menu"
PageTheme {
property string playlistName
property int playlistIndex
property int playlistSize
id: musicPage
toolbarTitle: playlistName + ": " + playlistSize + " songs"
function changePlaylist() {
var item = playlistModel.getPlaylistFromIndex(playlistIndex)
//note: using double ! to check item is not null or undefined (little JavaScript trick)
if(!!item)
else
console.log("playlist no good!!");
}
onPlaylistIndexChanged: changePlaylist()
MediaPlayer
{ id: playMusic autoLoad: true autoPlay: true //Component.onCompleted: changePlaylist() }_
In main.cpp playlistModel is created and made available to QML as follow:
_
PlayListModel playlistModel("/home/root");
QQmlApplicationEngine engine;
QQmlContext* context = engine.rootContext();
context->setContextProperty("playlistModel", &playlistModel);
_
Despite Q_DECLARE_METATYPE(QMediaPlaylist*) is declared, I got the error.