[Interest] Looks like a bug to me.
Philippe
philwave at gmail.com
Sun Jun 4 17:05:58 CEST 2017
qDebug() << QString("B: %4%1%2%3") .arg(b, c, d, a);
works
Philippe
On Mon, 5 Jun 2017 00:41:34 +1000
"Tony Rietwyk" <tony at rightsoft.com.au> wrote:
> > Sent: Sunday, 4 June 2017 11:26 PM
> >
> > Hello (No, this is not spam):
> >
> > For me, the following:
> >
> > QString a = "XXX";
> > QString b = "";
> > QString c = "";
> > QString d = "1";
> > qDebug() << QString("A: %1%2%3%4") .arg(a) .arg(b) .arg(c) .arg(d);
> > qDebug() << QString("B: %4%1%2%3") .arg(b) .arg(c) .arg(d) .arg(a);
> >
> > prints this:
> >
> > "A: XXX1" # As expected.
> > "B: XXX" # Expected: XXX1.
> >
> > I think the 'B:' line demonstrates a bug.
> > Where is the '1'?
> >
> > Qt 5.7
> > RedHat Enterprise Linux 6.8
> > gcc: 4.9.3
> >
> > Bill
>
> Hi Bill,
>
> For the second one, consider that after arg(d) is executed, the input string to arg(a) is "B: %41". Since 41 is now "the lowest numbered place marker", "XXX" gets substituted. It is easy to mistakenly think that QString magically treats multiple .args as somehow being indexed. I think the documentation for QString.arg should warn about your example, and the case when substituted strings contain %<number>.
>
> Regards, Tony
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list