PDA

View Full Version : Is this a bug or I'm doing it wrong? (resizing an item when resizing a window)



Zingam
12th December 2013, 12:22
Edit: I've missed to mention that I am using Qt 5.2

Here is the qml file from the OpenGL under Qml example:



//! [1]
import QtQuick 2.0
import OpenGLUnderQML 1.0

Item {
id: rectangle1
width: 320
height: 480

Squircle {
SequentialAnimation on t {
NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
loops: Animation.Infinite
running: true
}
}
//! [1]
//! [2]
Rectangle {
y: 0
height: 80
color: Qt.rgba(1, 1, 1, 0.7)
radius: 10
anchors.left: parent.left
anchors.leftMargin: 10
anchors.right: parent.right
anchors.rightMargin: 10
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
border.width: 1
}
}
//! [2]


And here is the same with a default hello world project:





import QtQuick 2.0

Item {
id: rectangle2
width: 360
height: 360
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
MouseArea {
id: mouseArea1
anchors.fill: parent
onClicked: {
Qt.quit();
}
}

Rectangle {
id: rectangle1
y: 235
height: 97
color: "#da8686"
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
anchors.right: parent.right
anchors.rightMargin: 10
anchors.left: parent.left
anchors.leftMargin: 10
}
}





And I'm attaching a screenshot too. The former doesn't work and I don't see any problem in the code. BTW. I am using the MinGW distribution.


I think there is a problem with anchors with this particular example (OpenGL under QML) and maybe that's a related issue.
The idea is to make a rectangle that re-sizes with the window.

If its not my oversight then I guess I should report a bug. I'm waiting for your opinions.

Please see the screenshot about the actual result:

Zingam
12th December 2013, 16:08
I guess it is an omission in the sample. This line is missing:

view.setResizeMode(QQuickView::SizeRootObjectToVie w);
Which is present in other samples like: "Scene Graph - Rendering FBOs"