Oh alright, so you basically want the part with the resizing, you already got your part done with the clicking?
For the resizing part you'll still need a resize function in your mainwindow class. Let's keep the old one from above. In QML you'll just resize your top-level-component.
If it is for example a Rectangle:
@Rectangle {
id: topLevelComp
// more code ..
}@
We'll give it an id. So if we have to resize the window, like for example with the onClicked: notification of a MouseArea, we just execute:
@onClicked: {
topLevelComp.width = 0
topLevelComp.height = 0
}@
The QML-resize part is mostly done. We now need a signal in our QML so we can call a Cpp function. For that we just declare it that way:
@Rectangle {
id: topLevelComp
signal resizeMyApplication()
// more code ..
}@
Now we can emit it in our onClicked notification:
@onClicked: {
topLevelComp.width = 0
topLevelComp.height = 0
resizeMyApplication()
}@
In Cpp we have got our QML-ApplicationViewer. For that case i'll use a QQuickView. We have to get the rootObject() of our Viewer:
@QQuickView *view = new QQuickView();
// ... some code
QObject *obj = (QObject *)view->rootObject();@
Now we just have to connect the signal with a given slot or signal, for example:
@connect(obj, SIGNAL(resizeMyApplication()), this, SLOT(resizeMe()));@
You'll need the resizeMe() slot for that. In the slot you just execute the void MainWindow::rescaleWindow(int w, int h, int x, int y) function. You can also put the resize directly into the slot:
@{
this->setGeometry(x, y, w, h);
}@
I hope that you'll understand what i mean and that i could help you. Feel free to ask for further informations or read this documentations:
"Qml Cpp Integration":http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-topic.html
"Interacting with QML Objects from Cpp ":http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-interactqmlfromcpp.html
"Thread on how to: invoke QML methods":http://qt-project.org/forums/viewthread/36154