Ignore invisible items inside Layout
-
Hi.
I have several buttons on the form, some of them should be hidden in some conditions. When I hide button placed inside ColumnLayout I get hole like:
!http://i.imgur.com/2o2FX5i.png(this)!
instead of expeced:
!http://i.imgur.com/LDPAKMt.png(that)!
Here is the code:
@import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0Rectangle {
width: 256
height: 128
ColumnLayout
{
anchors.margins: 8
anchors.fill: parent
Button
{
Layout.fillWidth: true
}
Button
{
visible: false
Layout.fillWidth: true
}
Button
{
Layout.fillWidth: true
}
}
}@How can I say Layout to ignore invisible items?
PS: Real app, that requires this: "my old thread":http://qt-project.org/forums/viewthread/27605/#124749
-
Don't know about the intention of QtQuick 5.0 Layouts module author (I'm wondering about this one myself, and also about the transition applicable to the Layouts elements), but a workaround is to use "Column":http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-column.html element instead, which will "hide" invisible elements:
bq. If an item within a Column is not visible, or if it has a width or height of 0, the item will not be laid out and it will not be visible within the column.
-
janarve, Jens, thanks for the info. Are QtQuick Layouts going to have an add, move or displaced transition then? What is the intended difference between the Layouts (GridLayout, ColumnLayout, RowLayout) and the standard positioners (Grid, Column, Row)?
-
@Alek: Animations are something we consider, but nothing has been decided yet.
I suggest you can look at the blog post to read about the differences between the Qt Quick Layouts and the Qt Quick Positioners: http://blog.qt.digia.com/blog/2013/05/16/introducing-qt-quick-layouts/