Dialog containing RowLayout not having correct window size
-
wrote on 29 Feb 2016, 19:50 last edited by topse
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 -
wrote on 29 Feb 2016, 21:42 last edited by
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" } } }
-
wrote on 29 Feb 2016, 23:21 last edited by
Did you provide a width for the Dialog as I did in my code?
-
wrote on 1 Mar 2016, 00:18 last edited by
No I didnt... sorry. But: Why do I have to? Manual says, that Dialog will figure out the size of the children by itself?
-
wrote on 1 Mar 2016, 05:17 last edited by
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.
-
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.
wrote on 1 Mar 2016, 08:00 last edited byOK. But I think then I may have a problem: The application will run on Windows and Android. I think, on both OS'ses the sizes of the Text and the TextField will be very different, because Android will use larger a Font. Do you have such a use-case?
Tobias
1/7