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
.
..
MovableWidget *view = new MovableWidget;
view
->setSource
(QUrl("qrc:/Test.qml"));
view->setWindowFlags(Qt::FramelessWindowHint);
view->show();
if (view->rootObject())
QObject::connect(view
->rootObject
(),
SIGNAL(signal_showMenu
(bool)), view,
SLOT(onMenuShown
(bool)));
...
..
MovableWidget *view = new MovableWidget;
view->setSource(QUrl("qrc:/Test.qml"));
view->setWindowFlags(Qt::FramelessWindowHint);
view->show();
if (view->rootObject())
QObject::connect(view->rootObject(), SIGNAL(signal_showMenu(bool)), view, SLOT(onMenuShown(bool)));
...
To copy to clipboard, switch view to plain text mode
MovableWidget.cpp
#include "movableWidget.h"
#include <QMouseEvent>
// ****************************************************************************
MovableWidget
::MovableWidget(QWidget *parent
) : QQuickWidget(parent)
{
}
// ****************************************************************************
void SptMiniWindow::onMenuShown(bool bShown)
{
// setGeometry() here? parameters??
}
#include "movableWidget.h"
#include <QMouseEvent>
// ****************************************************************************
MovableWidget::MovableWidget(QWidget *parent)
: QQuickWidget(parent)
{
}
// ****************************************************************************
void SptMiniWindow::onMenuShown(bool bShown)
{
// setGeometry() here? parameters??
}
To copy to clipboard, switch view to plain text mode
Test1.qml
import QtQuick 2.0
Rectangle {
id: myWindow
signal signal_showMenu(bool show)
width: 250; height: 100
color: "red"
Button {
id: idButtonClick
anchors { bottom: parent.bottom; bottomMargin: 10; horizontalCenter: parent.horizontalCenter }
height: 20
width: 50
text: "click"
onClicked: {
console.log("idButtonClick");
test2.visible = !test2.visible
// Here 'myWindow' height must be changed?
signal_showMenu(test2.visible)
}
Test2 {
id: test2
anchors { bottom: myWindow.top; left: myWindow.left; right: myWindow.right; }
height: 50
visible: false
}
}
import QtQuick 2.0
Rectangle {
id: myWindow
signal signal_showMenu(bool show)
width: 250; height: 100
color: "red"
Button {
id: idButtonClick
anchors { bottom: parent.bottom; bottomMargin: 10; horizontalCenter: parent.horizontalCenter }
height: 20
width: 50
text: "click"
onClicked: {
console.log("idButtonClick");
test2.visible = !test2.visible
// Here 'myWindow' height must be changed?
signal_showMenu(test2.visible)
}
Test2 {
id: test2
anchors { bottom: myWindow.top; left: myWindow.left; right: myWindow.right; }
height: 50
visible: false
}
}
To copy to clipboard, switch view to plain text mode
Test2.qml
import QtQuick 2.0
Rectangle {
color: "green"
}
import QtQuick 2.0
Rectangle {
color: "green"
}
To copy to clipboard, switch view to plain text mode
Bookmarks