Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-83834

Error Unknown method return type: QMediaPlaylist* passing *QMediaPlaylist from C++ to QML

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Quick: Other
    • 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)

      { playMusic.playlist = item; console.log("playlist changed!!"); }

      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.

      Attachments

        1. myplaylist.h
          0.5 kB
        2. playlistmodel.cpp
          5 kB
        3. playlistmodel.h
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            w00t Robin Burchell
            davidino Davide Brunelli
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes