i have listview , textarea below it. want height of listview increases or decreases respect size of textarea. tried anchoring bottom of listview textarea's top, didn't work. tried anchoring top of textarea bottom of listview, didn't work either. tried both together, neither that. everytime gives runtime error/warning of binding loop detected property "height" tried in textarea's scope, yet have same runtime error/warning , no results:
ontextchanged: { listview.anchors.bottommargin = height; }
how can achieve this?
here's code:
listview{ id: listview // anchors.fill: parent anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom anchors.bottommargin: 0 anchors.margins: 10 delegate: chatmessageitem{} model: listmodel spacing: 15 } rectangle{ id: rectinput height: childrenrect.height + 6 width: parent.width // anchors.top: listview.bottom anchors.bottom: parent.bottom color: "#bdc3c7" textarea{ id: tmsg placeholdertext: qstr("enter message") width: parent.width - 30 anchors.bottom: parent.bottom anchors.bottommargin: 2 anchors.left: parent.left anchors.leftmargin: 1 focus: true wrapmode: textarea.wrap background: rectangle { border.color: "#bdc3c7" border.width: 2 color: "#ecf0f1" } ontextchanged: { listview.anchors.bottommargin = height; } } }
import qtquick 2.3 import qtquick.window 2.2 import qtquick.controls 1.4 window { visible: true width : 500 height: 300 listmodel { id: contactmodel listelement { name: "bill smith" number: "555 3264" } listelement { name: "john brown" number: "555 8426" } listelement { name: "sam wise" number: "555 0473" } } component { id: contactdelegate item { width: 180; height: 80 column { text { text: '<b>name:</b> ' + name } text { text: '<b>number:</b> ' + number } } } } listview { id: listview anchors.top: parent.top; anchors.left: parent.left; anchors.right: parent.right; anchors.bottom: rectinput.top; model: contactmodel delegate: contactdelegate } rectangle{ id: rectinput height: tmsg.height+4; color: "#bdc3c7" anchors.bottom: parent.bottom width: parent.width textarea{ id: tmsg width: parent.width - 2 anchors.bottom: parent.bottom anchors.bottommargin: 2 anchors.left: parent.left anchors.leftmargin: 1 focus: true wrapmode: textarea.wrap } } }
a sample qml file works fine. when in doubt, simplify, fix problem , add bit bit.
in code:
height: childrenrect.height + 6
i don't see replacing childrenrect
defined anywhere. maybe replacing tmsg.height
, anchoring list's bottom rectangle's top work? works in sample file (i can't use code word-for-word because it's not complete on own).childrenrect
tmsg
removes binding loop error me.
by way: put bottom of list view rect's top, not text area's top inside rect:
anchors.bottom: rectinput.top
an alternative in list view:
anchors.bottom: parent.bottom anchors.bottommargin: tmsg.height
apart warning @ launch when text view not yet created, works fine too.