[Interest] Column's subitem doesn't show up again once being hidden
Dmitry Volosnykh
dmitry.volosnykh at gmail.com
Tue Jan 20 13:38:32 CET 2015
Hello,
I have a movie description which provides a number of text properties like
actors, producer, etc. plus a poster. In a short description of movie I'd
like to show only that number of properties (with text limited to a small
number of lines) which fit in the vertical area with the height as of the
poster's one. When one wants to see the full details all the properties
with no limitation are shown.
Here's how I try to do it (green rectangle is used as a replacement for the
poster):
import QtQuick 2.2
Row {
width: 600
height: 400
focus: true
property bool concise: true
Column {
width: 300
Repeater {
model: 3
Text {
id: text1
objectName: "text1"
width: parent.width
visible: !poster.excludes(text1)
text: "Lorem ipsum dolor sit amet, consectetur adipiscing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
maximumLineCount: concise ? 2 : undefined
wrapMode: Text.Wrap
elide: Text.ElideRight
Rectangle {
anchors.fill: parent
z: parent.z - 1
color: Qt.rgba(1 - index * 0.3, 0, index * 0.3)
}
}
}
}
Rectangle {
id: poster
width: 400
height: 75
color: "green"
function excludes(item) {
var outside = item.y + item.height > height
return (concise && outside)
}
}
Keys.onSpacePressed: concise = !concise
}
At initial load two of three text items are shown (which is correct) with
two lines each. Once I press space bar all three items are displayed
entirely. Now, when I press space bar again to get the initial
representation, I get only one item visible instead of two.
As far as I can understande, the second item get its 'visible' property
evaluated prior to change of its y position (which is expected to occur
once the first item shrinks along its height). This makes item invisible
since, while being fully displayed, it does not fit into the vertical area
associated with poster's height. And due to its invisibility its position
is not maintained/updated. Kind of dependency loop here... How to avoid it?
How can I make the second item appear again?
Regards,
Dmitry.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150120/60c81d76/attachment.html>
More information about the Interest
mailing list