Re: parentheses convention for C++ ?

"John W. Eaton" <[email protected]>
Newsgroups gmane.comp.gnu.octave.maintainers
Message-ID <[email protected]>
On 7/14/20 10:57 AM, Rik wrote:
> jwe,
> 
> Just checking the last cset I see:
> 
> ~/wip/Projects_Mine/octave-dev: hlog -p -r -1
> changeset:   28577:5c6b4cbd417f
> bookmark:    @
> tag:         tip
> user:        John W. Eaton <[email protected]>
> date:        Tue Jul 14 01:19:30 2020 -0400
> summary:     avoid deprecated Qt QString::sprintf function
> 
> diff -r 1afdc349b883 -r 5c6b4cbd417f 
> libgui/qterminal/libqterminal/unix/TerminalView.cpp
> --- a/libgui/qterminal/libqterminal/unix/TerminalView.cpp       Tue Jul 
> 14 01:09:31 2020 -0400
> +++ b/libgui/qterminal/libqterminal/unix/TerminalView.cpp       Tue Jul 
> 14 01:19:30 2020 -0400
> @@ -927,8 +927,7 @@ void TerminalView::showResizeNotificatio
>             connect(_resizeTimer, SIGNAL(timeout()), _resizeWidget, 
> SLOT(hide()));
> 
>           }
> -      QString sizeStr;
> -      sizeStr.sprintf("Size: %d x %d", _columns, _lines);
> +      QString sizeStr = QString("Size: %1 x %2").arg(_columns).arg(_lines);
>         _resizeWidget->setText(sizeStr);
> _resizeWidget->move((width()-_resizeWidget->width())/2,
> (height()-_resizeWidget->height())/2+20);
> 
> In Octave m-files, the convention is a space between the function name 
> and the parenthesis which starts the input parameter list.  Are we 
> trying to follow that in C++ as well?  For example, in the above code, 
> "_resizeWidget->setText(sizeStr)" there is no space between the member 
> function name setText and the parenthesis.  If this is the convention, 
> does it also apply to class constructors?  Should the code read 
> "QString(...)" or "QString (...)"?

Yes, I think that's normally what I would try do but this file is in the 
qterminal directory and I was attempting to follow the conventions used 
there.  It's code imported from another project that we're only making 
minimal changes to when necessary.  But then I also realized that's 
probably impossible because the style seems to be all over the place in 
those files.

jwe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.