[Qt-qml] Listview contentheight woes
amit shah
techlist.amit at gmail.com
Sat Feb 12 04:31:57 CET 2011
Hi,
I'am in a process of building a multi-line text viewer with scroll bars.
I have implemented my component MultiLineText in a separate file .
The MultiLine component has a ListView and I'm using contentHeight property
of ListView drive the logic for scrolling. I have not attached the
scrolling component code.
The problem is the contentHeight value is displaying as 200 which is the
height of the listview.
Here is the code, the driver code is implemented in focusKey.qml .
Any ideas as why contentHeight is not being calculated correctly.
thanks
--amit
File:focusKey.qml
=================
FocusScope {
width: 1280
height: 480
focus: true
Rectangle{
color: "#d32828"
border.color: "black"
anchors.fill: parent;
smooth:true
MultiLineText{
id:test
width: 300;height: 200;
anchors{top:parent.top;topMargin:100;left:parent.left;leftMargin:500}
opacity: 0.5
mlt_dataText:"
1Contrary to popular belief, Lorem Ipsum is not simply random
text. It has roots in a piece of classical Latin literature from 45 BC,
making it over 2000 years old. Richard McClintock, a Latin professor at
Hampden-Sydney College in Virginia, looked up one of the more obscure Latin
words, consectetur, from a Lorem Ipsum passage, and going through the cites
of the word in classical literature, discovered the undoubtable source.
Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et
Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC. This
book is a treatise on the theory of ethics, very popular during the
Renaissance. The first line of Lorem Ipsum, Lorem ipsum dolor sit amet..,
comes from a line in section 1.10.32
2Contrary to popular belief, Lorem Ipsum is not
simply random text. It has roots in a piece of classical Latin literature
from 45 BC, making it over 2000 years old. Richard McClintock, a Latin
professor at Hampden-Sydney College in Virginia, looked up one of the more
obscure Latin words, consectetur, from a Lorem Ipsum passage, and going
through the cites of the word in classical literature, discovered the
undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of
de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero,
written in 45 BC. This book is a treatise on the theory of ethics, very
popular during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum
dolor sit amet.., comes from a line in section 1.10.32
3Contrary to popular belief, Lorem Ipsum is not
simply random text. It has roots in a piece of classical Latin literature
from 45 BC, making it over 2000 years old. Richard McClintock, a Latin
professor at Hampden-Sydney College in Virginia, looked up one of the more
obscure Latin words, consectetur, from a Lorem Ipsum passage, and going
through the cites of the word in classical literature, discovered the
undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of
de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero,
written in 45 BC. This book is a treatise on the theory of ethics, very
popular during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum
dolor sit amet.., comes from a line in section 1.10.32
4ontrary to popular belief, Lorem Ipsum is not
simply random text. It has roots in a piece of classical Latin literature
from 45 BC, making it over 2000 years old. Richard McClintock, a Latin
professor at Hampden-Sydney College in Virginia, looked up one of the more
obscure Latin words, consectetur, from a Lorem Ipsum passage, and going
through the cites of the word in classical literature, discovered the
undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of
de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero,
written in 45 BC. This book is a treatise on the theory of ethics, very
popular during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum
dolor sit amet.., comes from a line in section 1.10.32
5Contrary to popular belief, Lorem Ipsum is not
simply random text. It has roots in a piece of classical Latin literature
from 45 BC, making it over 2000 years old. Richard McClintock, a Latin
professor at Hampden-Sydney College in Virginia, looked up one of the more
obscure Latin words, consectetur, from a Lorem Ipsum passage, and going
through the cites of the word in classical literature, discovered the
undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of
de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero,
written in 45 BC. This book is a treatise on the theory of ethics, very
popular during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum
dolor sit amet.., comes from a line in section 1.10.32
"
}
}
}
File: MultiLineText.qml
=====================
import Qt 4.7
Item {
id:scrollMultiLine
property string mlt_fontfamily;
property int mlt_fontSize:18;
// property alias mlt_dataText: scrollText.text
property string mlt_dataText;
// property alias mlt_color:scrollText.color
Component.onCompleted:{
console.log("Target Height="+target_B.height+"
ContentHeight"+target_B.contentHeight)
}
Component{
id:scrollTextDelegate
Text{
id:scrollText
anchors.fill: parent;
wrapMode:Text.WordWrap;
font.family: mlt_fontfamily;
font.pixelSize:0
text: mlt_dataText;
}
}
ListView{
id:target_B;
model: 1; clip: true
x:0;y:0;
width: parent.width;height: parent.height;
delegate:scrollTextDelegate
}
// ScrollBar{
// target: target_B
// }
}
=====================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110211/e62190f5/attachment.html
More information about the Qt-qml
mailing list