[Solved] Column with border



  • Is it possible to create a border around a Column element?
    I have tried to create a Rectangle around it:
    @
    Rectangle
    {
    color: "blue"
    radius: 5
    border.color: "black"
    border.width: 5

    Column
    {
        id: column
    
        anchors.fill: parent
        anchors.margins: 10
        ...
    }
    

    }
    @

    But the rectangle is not visible. Maybe I'm missing a property?
    Neither the background nor the border is visible.



  • Cannot see why that would not work. In fact, the following works just fine for me:
    @
    import QtQuick 1.0

    Rectangle {
    width: 100
    height: 100

    color: "blue"
    radius: 5
    border.color: "black"
    border.width: 5
    
    Column {
        anchors.fill: parent
        anchors.margins: 10
    
        Text { text: "Hello" }
        Text { text: "World" }
    }
    

    }
    @



  • You must set width and height or anchors for Rectangle element.



  • Thank you, I have set the height and width to the column.height and column.width. But this doesn't work. (Also anchors.fill: column) does not work.
    Do I always have to set these properties statically?


    edit: it is working now!

    @
    Rectangle
    {
    id: rectangle
    color: "#f3f3f3"
    radius: 5
    border.color: "#5e5b5b"
    border.width: 2
    width: 640;

    Column
    {
        id: column
        objectName: "column"
    
        anchors.margins: 1
        anchors.left: parent.left
        anchors.right: parent.right
        rectangle.height = height
        ...
    }
    

    }
    @



  • You don't have to set them statically, but they must be bound to something that eventually evaluates to real values. Using the column width and height creates a circular dependency that will never evaluate to a real value.



  • I think that this was my problem. I've edited my previous post, which now contains the code which was working for me.
    Thank you all for your help!


Log in to reply
 

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