[Solved] : Rotate complete window
-
Hi,
First, i would like to say that i'm pretty new in the Qt universe, so if the approach of my problem is wrong, correct me ^^
So here is my problem :
I'm working on an app with several specific behavior :
-
The window has 2 views, a small and a big, and the size change dynamically when clicking on a button
-
The window has to be transparent (the view has "holes" in it so you can see through it)
-
It has to be rotated 270 degrees (due to the specific configuration of the board i'm working with)
I have managed to make the two first conditions working pretty easily, but i'm can't find a way to make the last one working (rotation).
Anyone here has a solution ?
Here is my code :
main.cpp
@
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine(QUrl("qrc:/layouts/qml/main.qml"));return app.exec();
}@
main.qml
@
import QtQuick 2.2
import QtQuick.Controls 1.0ApplicationWindow {
id: qtWindowvisible: true flags: Qt.FramelessWindowHint color: "transparent" width: smallView.width height: smallView.height Item { id: qtView /*transform: Rotation { angle: 270 origin.x: qtView.width / 2 origin.y: qtView.height / 2 }*/ LargeView { id:largeView visible: false } SmallView { id:smallView visible: true onDisplaySelectedLargeScreenButtonPressed: { switchToLargeScreenMode() } } states: [ State { name: "Opened" PropertyChanges { target: largeView visible: true } PropertyChanges { target: smallView visible: false } }, State { name: "Closed" PropertyChanges { target: largeView visible: false } PropertyChanges { target: smallView visible: true } }, ] focus: true Keys.onPressed: { toogleScreenMode() } } function switchToSmallScreenMode() { console.debug("switchToSmallScreenMode") qtWindow.height = smallView.height qtView.state = "Closed" } function switchToLargeScreenMode() { console.debug("switchToLargeScreenMode") qtWindow.height = largeView.height qtView.state = "Opened" }
@
As you can see in the qml file, i tried to use the transfrom:rotation element, but this solution make my app disappear.
I'm working with qt everywhere 5.2 with qtcreator 3.1 on ubuntu 12.04.
Thx
-
-
I finally managed to solved my problem by myself.
With the actual rotation code, the axis of rotation wasn't correct to rotate and keep the right position (left and upper side unmoved). With this previous wrong axis, the app was designed outside the screen.To made a correct rotation, i used this code :
@
transform: Rotation {
id: rotation
angle: targetIsEmbeded ? rotationAngle : 0
origin.x: (targetIsEmbeded ? (rotationAngle == 90 ? qtWindow.width / 2 : (rotationAngle == 270 ? qtWindow.height / 2 : 0)) : 0)
origin.y: origin.x
}
@