0
down vote
favorite
I have a QQuickWidget (MovableWidget) with a QML inside (QML1: Test.qml)

This QML has a button, and when clicked I want to show/hide another QML (Test2.qml) above QML2, but not in another window (in Windows, both panels must be in the same 'Task bar' window). QML1 must keep the position in both cases, with QML1 visible or hidden

I tried to add a QML2 instance inside QML1, setting it above, but I can not paint outside QML1 boundaries. So I suppose I must increase QML1 size, and so TestWidget size, but in this case the best thing I have achieved is that the window is increased but to the bottom...

main.cpp

.
Qt Code:
  1. ..
  2. MovableWidget *view = new MovableWidget;
  3. view->setSource(QUrl("qrc:/Test.qml"));
  4. view->setWindowFlags(Qt::FramelessWindowHint);
  5. view->show();
  6. if (view->rootObject())
  7. QObject::connect(view->rootObject(), SIGNAL(signal_showMenu(bool)), view, SLOT(onMenuShown(bool)));
  8. ...
To copy to clipboard, switch view to plain text mode 

MovableWidget.cpp
Qt Code:
  1. #include "movableWidget.h"
  2.  
  3. #include <QMouseEvent>
  4.  
  5. // ****************************************************************************
  6. MovableWidget::MovableWidget(QWidget *parent)
  7. : QQuickWidget(parent)
  8. {
  9. }
  10.  
  11. // ****************************************************************************
  12. void SptMiniWindow::onMenuShown(bool bShown)
  13. {
  14. // setGeometry() here? parameters??
  15. }
To copy to clipboard, switch view to plain text mode 

Test1.qml

Qt Code:
  1. import QtQuick 2.0
  2.  
  3. Rectangle {
  4. id: myWindow
  5.  
  6. signal signal_showMenu(bool show)
  7.  
  8. width: 250; height: 100
  9. color: "red"
  10.  
  11. Button {
  12. id: idButtonClick
  13.  
  14. anchors { bottom: parent.bottom; bottomMargin: 10; horizontalCenter: parent.horizontalCenter }
  15.  
  16. height: 20
  17. width: 50
  18.  
  19. text: "click"
  20.  
  21. onClicked: {
  22. console.log("idButtonClick");
  23. test2.visible = !test2.visible
  24.  
  25. // Here 'myWindow' height must be changed?
  26.  
  27. signal_showMenu(test2.visible)
  28. }
  29.  
  30. Test2 {
  31. id: test2
  32. anchors { bottom: myWindow.top; left: myWindow.left; right: myWindow.right; }
  33. height: 50
  34. visible: false
  35. }
  36. }
To copy to clipboard, switch view to plain text mode 
Test2.qml
Qt Code:
  1. import QtQuick 2.0
  2.  
  3. Rectangle {
  4. color: "green"
  5. }
To copy to clipboard, switch view to plain text mode