1

I have a QML ListView and I want to access to the delegate children in c++

main.qml

ApplicationWindow {
    objectName: "wnd1"
    ListView {
        objectName: "mediaPlayerListView"
        model: provider.mediaPlayerItems
        delegate: MediaPlayerDelegate
    }
}

MediaPlayerDelegate.qml

Row {
    objectName: "mainRow"

    VideoOutput {
      objectName: "videoOutput" + modelData.id
}

Here is the c++ code I've tried

QString currentId = "1";

QQuickWindow *mainWindow = _qmlAppEngine->rootObjects()[0]->findChild<QQuickWindow *>("wnd1");

QObject *mediaPlayerListView = mainWindow->findChild<QObject *>("mediaPlayerListView");

QObject *mediaPlayerListViewDelegate = mediaPlayerListView->property("delegate").value<QObject *>();

I want to be able to get in cpp the videoOutput, doing something like this

QObject *videoOutput = mediaPlayerListViewDelegate->findChild<QObject *>("videoOutput" + currentId)

But I can't access further than the delegate, it has no children.

Léo S.
  • 11
  • 1
  • see https://stackoverflow.com/questions/36767512/how-to-access-qml-listview-delegate-items-from-c – ניר Nov 30 '22 at 19:09
  • Does this answer your question? [How to access QML ListView delegate items from C++?](https://stackoverflow.com/questions/36767512/how-to-access-qml-listview-delegate-items-from-c) – ניר Nov 30 '22 at 19:09

0 Answers0