Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-109089

qmlcachegen/qmlsc: Warn if an Item in a Layout specifies `width` instead of `Layout.preferredWidth`

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • 6.9
    • None
    • QML: Tooling

    Description

      This code contains a simple mistake that is not obvious to many:

      import QtQuick
      import QtQuick.Layouts
      
      Window {
          width: 640
          height: 480
          visible: true
      
          ColumnLayout {
              width: 50
              height: 50
      
              Image {
                  width: 50
                  height: 50
                  sourceSize.width: 100
                  sourceSize.height: 100
                  source: "circle.svg"
              }
          }
      }
      

      The resulting image will be 100x100, even though the layout's width and height are equal to the Image's specified width and height.

      It would be good for tooling to point out that width/height are ignored, and suggest using Layout.preferredWidth/Layout.preferredHeight instead.

       

      Update

      qmllint does provide this warning, but it needs to be manually run as it is currently not integrated with Qt Creator or qmlcachegen/qmlsc. It would be helpful for users to get these warnings at edit-time and/or compile-time.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtqmlteam Qt Qml Team User
              skoh-qt Sze Howe Koh
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes