[Development] Suggesting update brace placement following a multi-line if condition
Stan Morris
pixelgrease at gmail.com
Mon Jul 20 06:34:37 CEST 2026
On Sunday, 19 July 2026 14:34:24 Pacific Daylight Time Lorn Potter wrote:
> > To make the original more readable, simply use a new blank line after
> the opening brace.
>
Does a blank line following the attached brace help enough?
Consider the following blocks from qtextedit.cpp:
if (cursor.atBlockStart()
&& (d->autoFormatting & AutoBulletList)
&& (text.size() == 1)
&& (text.at(0) == u'-' || text.at(0) == u'*')
&& (!cursor.currentList())) {
d->createAutoBulletList();
e->accept();
return;
}
and
if (!doc->pageSize().isNull()
&& alignmentProperty.userType() == QMetaType::Bool
&& !alignmentProperty.toBool()) {
d->adjustScrollbars();
return;
}
> >...
> and ewww.. that new style would bother me because it looks out of place.
Multiline if statements are one of the weaknesses in K&R braces. The
qtextedit.cpp code handles them cleanly. An Allman brace also works, but it
looks out-of-place when I try it out in qedittext.cpp.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20260719/9c021607/attachment.htm>
More information about the Development
mailing list