Dialog containing RowLayout not having correct window size



  • 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):

    Picture Here

    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" }
                }
     }
    


  • Ahhh... its getting better. Still a little problem, see picture:

    Picture2

    The TextEdit is not completly fit in the window... you know, why?

    Thanks again :-/



  • Did you provide a width for the Dialog as I did in my code?



  • No I didnt... sorry. But: Why do I have to? Manual says, that Dialog will figure out the size of the children by itself?



  • 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.



  • OK. 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.