[SOLVED]resizing window doesn't resize gui element
-
Hi,
Have a component and loading through element. When I resize window, it's not increasing width as per parent window. How to handle this? Should I handle onWidthChanged property?
@Component { id: testui Rectangle { width: 500 height: 500 color: "red" } } Loader { sourceComponent:testui anchors.top: anothercontrol.bottom width: parent.width }@
Thanks.
-
Hmmmm, your source is wrong or not complete so it's a little bit complicated to understand what you want. But if you want that your Loader change it's width when you resize it's parent you need to use anchors.
@
ApplicationWindow {
width: 640
height: 480
Rectangle {
anchors.fill: parent //to fill the entire AppWindow
Loader {
id: toolBar
// You can set the properties here or in the file did the same
anchors.left: parent.left
anchors.right: parent.right
height: 35
source: Qt.resolvedUrl("File.qml")
}
Rectangle {
anchors.top: toolBar.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
color: #ffff00
}
}
}
@ -
I can't see left and right properties for toolbar. I am using component.
when I maximize window, it will show rectangle for 640 * 50. Not maximizing as per parent window. How to do that?
working code:
@ApplicationWindow {
width: 640
height: 480Item { Loader { id: testloader anchors.top: parent.top sourceComponent: rect } Component { id: rect Rectangle { width: 640 height: 50 color: "red" anchors.left: parent.left//error anchors.right: parent.right//error } } }
}@
-
First problem:
Take a look: "HERE...":http://qt-project.org/doc/qt-5/qml-qtqml-component.html
Because Component is not derived from Item, you cannot anchor anything to itSecond problem:
You can not set width and anchors.left/anchors.right only one of them.Sorry but can you explain me what you want to do, why the loader? Why the component? I did an update of my example so maybe its right for you now.
-
OK, yeah for this you can use Loader, i tried another update, i'm not at home so no guaranty :)
-
so please mark all your solved threads as solved
-
Simply change the thread title like all the other solved threads here :)