Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column

Tags:

qt

qml

file:///home/biergaizi/WeCase.commit/src//ui/SmileyDelegate.qml:6:5: 
QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn 
anchors for items inside Column

Why I got that? I tried to comment each line without find answer. I do not have any idea with it.

SmileyView.qml

import QtQuick 1.0

Rectangle {
    width: 300; height: 200


    GridView {
        id: grid
        anchors.fill: parent
        cellWidth: 36; cellHeight: 40

        model: SmileyModel
        delegate: SmileyDelegate {}
        highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
        focus: true
    }
}

SmileyDelegate.qml

import QtQuick 1.0

Item {
    width: grid.cellWidth; height: grid.cellHeight

    Column {
        anchors.fill: parent
        Image { source: path; anchors.horizontalCenter: parent.horizontalCenter }
        Text { text: name; anchors.horizontalCenter: parent.horizontalCenter }

        MouseArea {
            anchors.fill: parent
            onClicked: {
                highlight: color: "lightsteelblue"; radius: 5 
                grid.currentIndex = index 
            }
            onDoubleClicked: {
                parentWindow.returnSmileyName('[' + name + ']')
            }
        }
    }
}
like image 605
比尔盖子 Avatar asked Apr 08 '13 04:04

比尔盖子


1 Answers

Column is trying to anchor your MouseArea to next to the Image and the Text, but the MouseArea specifies its anchor to fill its parent. Those two things are contradictory, and hence why you get the error.

You'll probably find it works as you expect if you move the MouseArea out of Column and into the base Item for SmileyDelegate.

like image 177
cgmb Avatar answered Sep 18 '22 14:09

cgmb