How to make QML items to grow to fit contents?

前端 未结 3 1225
广开言路
广开言路 2021-01-01 09:37

How to make ServerItem to grow to fit contents? Right now ServerItems just overlap each other.

main.qml

import Qt 4.7
import \"Teeworlds\" as Teeworl         


        
3条回答
  •  灰色年华
    2021-01-01 10:06

    Actually that's quite easy. The ServerItem objects have no size, you can only see the content because there is no clipping. The solution would be either to set height and width in the ServerItem class (or the instances in main.qml) or to use a growing element, e.g. a Column, as the ServerItem root element.

    import QtQuick 1.0
    
    Column {
        id: serverItem
    
        BorderImage {
            anchors.fill: parent
        }
    
        //... the rest
    }
    

提交回复
热议问题