Dialog containing RowLayout not having correct window size
Solved
QML and Qt Quick
-
Hi,
Sorry -- I really dont get it. Strong feeling of beeing dump :-/I want to create a Dialog with QML containing a RowLayout but when showing the dialog, the window size is not corrent.
The Dialog looks like that (its the best result I got after several combinations with width, implicitWidth and Layout.fill):
import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 import QtQuick.Dialogs 1.2 Dialog { id: kursDialog standardButtons: StandardButton.Cancel | StandardButton.Ok Item { id: item RowLayout { id: layout Text { id: label1 text: "Name des Kurses: " } TextField { id: nameField placeholderText: "Name des Kurses" } } } }
Can anyone give me a hint, what is going wrong here?
Thanks and Best Regards,
Tobias -
Your Item has no width/height, so the Dialog might have trouble laying it out. You could get rid of the Item, or give it a size. This works for me:
Dialog { standardButtons: StandardButton.Cancel | StandardButton.Ok width: 300 Item { width: childrenRect.width height: childrenRect.height RowLayout { Text { text: "Name des Kurses: " } TextField { placeholderText: "Name des Kurses" } } }
-
Manual says, that Dialog will figure out the size of the children by itself?
But it doesn't say that; it says it will attempt to size itself. From my experiences, it often fails.