I use Qt5.12.0 on windows 10, I want to see if it's possible to set a qml window into my rootObject qml application window and draw in front of this child window.

Here is my actually code.

main.qml

Qt Code:
  1. import QtQuick 2.9
  2. import QtQuick.Window 2.2
  3.  
  4. Window {
  5. visible: true
  6. width: 640
  7. height: 480
  8. title: qsTr("Hello World")
  9. color: "transparent"
  10. }
To copy to clipboard, switch view to plain text mode 
main.cpp

Qt Code:
  1. #include <QApplication>
  2. #include <QQmlApplicationEngine>
  3.  
  4. #include "video.h"
  5.  
  6. #include <QQuickWindow>
  7. #include <QUrl>
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11. QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  12.  
  13. QApplication app(argc, argv);
  14.  
  15. QQmlApplicationEngine engine;
  16. engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  17. if (engine.rootObjects().isEmpty())
  18. return -1;
  19.  
  20.  
  21. QQuickWindow* window;
  22. window = qobject_cast<QQuickWindow*>(engine.rootObjects().at(0));
  23.  
  24. CVideo *_pVideo = new CVideo();
  25. _pVideo->init(&engine, window);
  26.  
  27. return app.exec();
  28. }
To copy to clipboard, switch view to plain text mode 
video.h

Qt Code:
  1. #ifndef VIDEO_H
  2. #define VIDEO_H
  3.  
  4. #include <QQmlApplicationEngine>
  5. #include <QQuickWindow>
  6.  
  7. class CVideo
  8. {
  9. public:
  10. CVideo() = default;
  11. void init(QQmlApplicationEngine* _engine, QQuickWindow* _pWindow);
  12. };
  13.  
  14. #endif
To copy to clipboard, switch view to plain text mode 
video.cpp

Qt Code:
  1. #include "video.h"
  2.  
  3. #include <gst/gst.h>
  4. #include <gst/video/videooverlay.h>
  5.  
  6. #include <QQmlComponent>
  7. #include <QQuickItem>
  8. #include <QQuickWindow>
  9.  
  10. void CVideo::init(QQmlApplicationEngine* _engine, QQuickWindow* _pWindow)
  11. {
  12. gst_init(nullptr, nullptr);
  13. GstElement *pipeline =
  14. gst_parse_launch
  15. (
  16. "rtspsrc location=rtsp://192.168.1.168:554/hdmi latency=50 ! application/x-rtp,media=(string)video ! decodebin ! glimagesink",
  17. nullptr);
  18. GstElement *sink = gst_bin_get_by_name(GST_BIN(pipeline), "sink");
  19.  
  20.  
  21. WId xwinid = -1;
  22. QQmlComponent *_pComponent = new QQmlComponent(_engine, QUrl(QStringLiteral("QML/VideoItem.qml")), _pWindow);
  23. QQuickItem* _pVideoItem = qobject_cast<QQuickItem*>(_pComponent->create());
  24. _pVideoItem->setParent(_pWindow);
  25.  
  26. _pVideoItem->setParentItem(_pWindow->contentItem());
  27. _pVideoItem->setProperty("id", "_videoOutput");
  28. QObject *_pRootObject = dynamic_cast<QObject*>(_engine->rootObjects().first());
  29. QList<QWindow*> _allWindow = _pRootObject->findChildren<QWindow*>();
  30. QWindow *_window = _allWindow.first();
  31. xwinid = _window->winId();
  32. gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), xwinid);
  33. _window->setParent(_pWindow);
  34.  
  35. GstStateChangeReturn sret = gst_element_set_state (pipeline,
  36. GST_STATE_PLAYING);
  37. if (sret == GST_STATE_CHANGE_FAILURE) {
  38. gst_element_set_state (pipeline, GST_STATE_NULL);
  39. gst_object_unref (pipeline);
  40. }
  41. }
To copy to clipboard, switch view to plain text mode 
VideoItem.qml

Qt Code:
  1. import QtQuick 2.0
  2. import QtQuick.Window 2.3
  3. import QtQuick.Controls 2.4
  4.  
  5. Item{
  6. id: _video
  7. x: 0
  8. y: 0
  9. width: 1280
  10. height: 800
  11. visible: true
  12.  
  13. Window{
  14. id: _videoOutput
  15. visible: true
  16. x: 100
  17. y: 100
  18. width: 800
  19. height: 600
  20. }
  21.  
  22. Button{
  23. id: _button
  24. x: 10
  25. y: 10
  26. width: 100
  27. height: 100
  28. text: "test"
  29. }
  30. }
To copy to clipboard, switch view to plain text mode 
With this code I see my video read by gstreamer (1.14.4) but my button is under the video, so I want it in front of it.

It's possible to draw qml item (label, button, image,...) in front of my video item ? Thanks in advance for your response.