[Interest] RowLayout with Text with wrap mode

Pierre-Yves Siret py.siret at gmail.com
Tue Mar 6 00:02:29 CET 2018


My BTW remarks aren't the problems. Those remarks apply for all Item, not
only ListView delegates.

width: parent.width has no effect if both anchors.left and anchors.right
are set (this is the case with anchors.fill)
anchors.left: parent.left with no margins/leftMargin is the same as x: 0,
the default unless you are in parent managing your x position (Row,
RowLayout, Horizontal ListView, Grid, GridLayout, GridView and also Control
with padding ?). When in a parent like those mentioned you should not set
the x value.

parent size and anchors work in a ListView provided you are using
horizontal anchors or size in a Vertical ListView and vice-versa.
You part about *Layout is true outside a delegate also.

2018-03-05 19:36 GMT+01:00 Jérôme Godbout <godboutj at amotus.ca>:

> your BTW is the problems, parent size and anchors are not really working
> into a ListView delegate, which make some component reuse a bit hard with
> ListView sometime. When using a Layout into the delegate it's only the
> layout sizing that will have effect (normal size or other parent filll got
> ignored). If you don't see any problems with that, fine, I do.
>
> ------------------------------
> *From:* gr3cko at gmail.com <gr3cko at gmail.com> on behalf of Pierre-Yves
> Siret <py.siret at gmail.com>
> *Sent:* Monday, March 5, 2018 9:00 AM
> *To:* Jérôme Godbout
> *Cc:* Igor Mironchik; Qt Project
>
> *Subject:* Re: [Interest] RowLayout with Text with wrap mode
>
> You should always set a width for Text items (and a wrapMode and/or elide
> mode), unless you want your text to have no horizontal limit.
> In your case you need to correct your code (it's not a workaround since
> it's the intended behaviour) is to set a width for your Texts (the 3).
> Do this by using `Layout.fillWidth: true`.
>
> BTW : your width: parent.width and anchors.left: parent.left have no
> effect here
>
> I have not met the problems mentionned by Jérôme and using ListView is
> perfectly fine with me.
>
>
> 2018-03-05 14:42 GMT+01:00 Jérôme Godbout <godboutj at amotus.ca>:
>
> All the *View* type are a bit of a pain with Layout item. You need to
> specify the height and width properly with the Layout.minimumWidth/Height
> and maximum values. If you don't need all the animation stuff from
> ListView, you can do a simple GridLayout and fill the element which would
> be way simpler and you will have full control on the sizing without the
> pain.
>
> I for one, try to avoid the *View* element as much as possible. Good
> GridLayout make it easier and you can even declare the items by specifying
> the columns and row making a different repeater by row or by column
> possible.
>
> ------------------------------
> *From:* Interest <interest-bounces+godboutj=amotus.ca at qt-project.org> on
> behalf of Igor Mironchik <igor.mironchik at gmail.com>
> *Sent:* Saturday, March 3, 2018 4:18 AM
> *To:* Qt Project
> *Subject:* Re: [Interest] RowLayout with Text with wrap mode
>
> I know that changing RowLayout to simple Row will solve the problem. But
> is it possible to solve this with layout?
>
>
> On 03.03.2018 10:24, Igor Mironchik wrote:
> > Hello,
> >
> > I have a delegate for ListView with RowLayout inside:
> >
> > RowLayout {
> >                 anchors.fill: parent
> >                 spacing: 20
> >                 width: parent.width
> >
> >                 ColumnLayout {
> >                     id: col
> >                     anchors.left: parent.left
> >                     spacing: 5
> >
> >                     Text {
> >                         text: type === 0 ? qsTr( "<b>Place: </b>" ) +
> > model[ "PlaceRole" ] :
> >                             qsTr( "<b>Code: </b>" ) + model[ "CodeRole" ]
> >                     }
> >
> >                     Text {
> >                         text: qsTr( "<b>Amount: </b>" ) + model[
> > "AmountRole" ]
> >                     }
> >                 }
> >
> >                 Text {
> >                     text: model[ "DescRole" ]
> >                     wrapMode: Text.WordWrap
> >                 }
> >             }
> >
> >
> > All is fine with except that the last Text item doesn't wrap text. How
> > can I workaround it? Thanks.
> >
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180306/a78932df/attachment.html>


More information about the Interest mailing list