Skip to content

Commit 3eac688

Browse files
Documentation: Add \nullptr macro and use where applicable
Qt for Python users reading the documentation assume that int(0) can be passed for pointer parameters. Use the newly introduced \nullptr to disambiguate this. In a follow-up step, the \nullptr macro can be defined as None when generating the Qt for Python documentation. Task-number: PYSIDE-903 Change-Id: I3a45f87175a0668ab5f3f95f0aff409f7e3ef027 Reviewed-by: Cristian Maureira-Fredes <[email protected]> Reviewed-by: Christian Tismer <[email protected]> Reviewed-by: Venugopal Shivashankar <[email protected]> Reviewed-by: Paul Wicking <[email protected]>
1 parent 574b569 commit 3eac688

36 files changed

+62
-61
lines changed

doc/global/macros.qdocconf

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ macro.macos = "macOS"
1414
macro.menu = "\\b"
1515
macro.oslash.HTML = "&oslash;"
1616
macro.ouml.HTML = "&ouml;"
17+
macro.nullptr = "\\c{nullptr}"
1718
macro.QA = "\\e{Qt Assistant}"
1819
macro.QD = "\\e{Qt Designer}"
1920
macro.QL = "\\e{Qt Linguist}"

src/gui/accessible/qaccessible.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ void QAccessible::removeActivationObserver(ActivationObserver *observer)
654654
/*!
655655
If a QAccessibleInterface implementation exists for the given \a object,
656656
this function returns a pointer to the implementation; otherwise it
657-
returns 0.
657+
returns \nullptr.
658658
659659
The function calls all installed factory functions (from most
660660
recently installed to least recently installed) until one is found
@@ -770,7 +770,7 @@ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
770770
/*!
771771
Returns the QAccessibleInterface belonging to the \a id.
772772
773-
Returns 0 if the id is invalid.
773+
Returns \nullptr if the id is invalid.
774774
*/
775775
QAccessibleInterface *QAccessible::accessibleInterface(Id id)
776776
{
@@ -1119,7 +1119,7 @@ QAccessibleInterface *QAccessibleInterface::focusChild() const
11191119
\fn QAccessibleInterface *QAccessibleInterface::childAt(int x, int y) const
11201120
11211121
Returns the QAccessibleInterface of a child that contains the screen coordinates (\a x, \a y).
1122-
If there are no children at this position this function returns 0.
1122+
If there are no children at this position this function returns \nullptr.
11231123
The returned accessible must be a child, but not necessarily a direct child.
11241124
11251125
This function is only relyable for visible objects (invisible
@@ -1139,7 +1139,7 @@ QAccessibleInterface *QAccessibleInterface::focusChild() const
11391139
11401140
Returns the QAccessibleInterface of the parent in the accessible object hierarchy.
11411141
1142-
Returns 0 if no parent exists (e.g. for the top level application object).
1142+
Returns \nullptr if no parent exists (e.g. for the top level application object).
11431143
11441144
\sa child()
11451145
*/
@@ -1150,7 +1150,7 @@ QAccessibleInterface *QAccessibleInterface::focusChild() const
11501150
Returns the accessible child with index \a index.
11511151
0-based index. The number of children of an object can be checked with childCount.
11521152
1153-
Returns 0 when asking for an invalid child (e.g. when the child became invalid in the meantime).
1153+
Returns \nullptr when asking for an invalid child (e.g. when the child became invalid in the meantime).
11541154
11551155
\sa childCount(), parent()
11561156
*/
@@ -1356,7 +1356,7 @@ QAccessibleEvent::~QAccessibleEvent()
13561356
\internal
13571357
Returns the uniqueId of the QAccessibleInterface represented by this event.
13581358
1359-
In case the object() function returns 0 this is the only way to access the
1359+
In case the object() function returns \nullptr, this is the only way to access the
13601360
interface.
13611361
*/
13621362
QAccessible::Id QAccessibleEvent::uniqueId() const
@@ -1786,7 +1786,7 @@ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const
17861786
(This means that at least one interface among the ancestors should
17871787
return a valid QWindow pointer).
17881788
1789-
The default implementation returns 0.
1789+
The default implementation returns \nullptr.
17901790
*/
17911791
QWindow *QAccessibleInterface::window() const
17921792
{

src/gui/image/qimage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ QImageData::QImageData()
113113
\internal
114114
115115
Creates a new image data.
116-
Returns 0 if invalid parameters are give or anything else failed.
116+
Returns \nullptr if invalid parameters are give or anything else failed.
117117
*/
118118
QImageData * QImageData::create(const QSize &size, QImage::Format format)
119119
{

src/gui/itemmodels/qstandarditemmodel.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,8 @@ QStandardItem::~QStandardItem()
879879
}
880880

881881
/*!
882-
Returns the item's parent item, or 0 if the item has no parent.
883-
\note For toplevel items parent() returns 0. To receive toplevel
882+
Returns the item's parent item, or \nullptr if the item has no parent.
883+
\note For toplevel items parent() returns \nullptr. To receive toplevel
884884
item's parent use QStandardItemModel::invisibleRootItem() instead.
885885
886886
\sa child(), QStandardItemModel::invisibleRootItem()
@@ -1548,7 +1548,7 @@ QModelIndex QStandardItem::index() const
15481548
Returns the QStandardItemModel that this item belongs to.
15491549
15501550
If the item is not a child of another item that belongs to the model, this
1551-
function returns 0.
1551+
function returns \nullptr.
15521552
15531553
\sa index()
15541554
*/
@@ -1865,7 +1865,7 @@ void QStandardItem::setChild(int row, int column, QStandardItem *item)
18651865

18661866
/*!
18671867
Returns the child item at (\a row, \a column) if one has been set; otherwise
1868-
returns 0.
1868+
returns \nullptr.
18691869
18701870
\sa setChild(), takeChild(), parent()
18711871
*/
@@ -1881,7 +1881,7 @@ QStandardItem *QStandardItem::child(int row, int column) const
18811881
/*!
18821882
Removes the child item at (\a row, \a column) without deleting it, and returns
18831883
a pointer to the item. If there was no child at the given location, then
1884-
this function returns 0.
1884+
this function returns \nullptr.
18851885
18861886
Note that this function, unlike takeRow() and takeColumn(), does not affect
18871887
the dimensions of the child table.
@@ -2283,7 +2283,7 @@ void QStandardItemModel::clear()
22832283
itemPrototype()), and set it in the parent item's child table, if no item
22842284
already exists at that index.
22852285
2286-
If \a index is an invalid index, this function returns 0.
2286+
If \a index is an invalid index, this function returns \nullptr.
22872287
22882288
\sa indexFromItem()
22892289
*/
@@ -2380,7 +2380,7 @@ void QStandardItemModel::setItem(int row, int column, QStandardItem *item)
23802380
\since 4.2
23812381
23822382
Returns the item for the given \a row and \a column if one has been set;
2383-
otherwise returns 0.
2383+
otherwise returns \nullptr.
23842384
23852385
\sa setItem(), takeItem(), itemFromIndex()
23862386
*/
@@ -2453,7 +2453,7 @@ void QStandardItemModel::setHorizontalHeaderItem(int column, QStandardItem *item
24532453
\since 4.2
24542454
24552455
Returns the horizontal header item for \a column if one has been set;
2456-
otherwise returns 0.
2456+
otherwise returns \nullptr.
24572457
24582458
\sa setHorizontalHeaderItem(), verticalHeaderItem()
24592459
*/
@@ -2509,7 +2509,7 @@ void QStandardItemModel::setVerticalHeaderItem(int row, QStandardItem *item)
25092509
\since 4.2
25102510
25112511
Returns the vertical header item for row \a row if one has been set;
2512-
otherwise returns 0.
2512+
otherwise returns \nullptr.
25132513
25142514
\sa setVerticalHeaderItem(), horizontalHeaderItem()
25152515
*/

src/gui/kernel/qevent.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3072,7 +3072,7 @@ QDropEvent::~QDropEvent()
30723072
/*!
30733073
If the source of the drag operation is a widget in this
30743074
application, this function returns that source; otherwise it
3075-
returns 0. The source of the operation is the first parameter to
3075+
returns \nullptr. The source of the operation is the first parameter to
30763076
the QDrag object used instantiate the drag.
30773077
30783078
This is useful if your widget needs special behavior when dragging
@@ -3514,7 +3514,7 @@ QActionEvent::~QActionEvent()
35143514
\fn QAction *QActionEvent::before() const
35153515
35163516
If type() is \l ActionAdded, returns the action that should
3517-
appear before action(). If this function returns 0, the action
3517+
appear before action(). If this function returns \nullptr, the action
35183518
should be appended to already existing actions on the same
35193519
widget.
35203520

src/gui/kernel/qguiapplication.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,7 @@ Qt::LayoutDirection QGuiApplication::layoutDirection()
37473747
37483748
Returns the active application override cursor.
37493749
3750-
This function returns 0 if no application cursor has been defined (i.e. the
3750+
This function returns \nullptr if no application cursor has been defined (i.e. the
37513751
internal cursor stack is empty).
37523752
37533753
\sa setOverrideCursor(), restoreOverrideCursor()

src/gui/kernel/qopenglcontext.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ void QOpenGLContext::swapBuffers(QSurface *surface)
11181118
/*!
11191119
Resolves the function pointer to an OpenGL extension function, identified by \a procName
11201120
1121-
Returns 0 if no such function can be found.
1121+
Returns \nullptr if no such function can be found.
11221122
*/
11231123
QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName) const
11241124
{

src/gui/kernel/qplatformcursor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ QT_BEGIN_NAMESPACE
8484
8585
\a windowCursor is a pointer to the QCursor that should be displayed.
8686
87-
To unset the cursor of \a window, 0 is passed. This means \a window does not have
87+
To unset the cursor of \a window, \nullptr is passed. This means \a window does not have
8888
a cursor set and the cursor of a the first parent window which has a cursor explicitly
8989
set or the system default cursor should take effect.
9090

src/gui/kernel/qplatformintegration.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void QPlatformIntegration::destroy()
350350
/*!
351351
Returns the platforms input context.
352352
353-
The default implementation returns 0, implying no input method support.
353+
The default implementation returns \nullptr, implying no input method support.
354354
*/
355355
QPlatformInputContext *QPlatformIntegration::inputContext() const
356356
{

src/gui/kernel/qplatformscreen.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ QString QPlatformScreen::serialNumber() const
370370
/*!
371371
Reimplement this function in subclass to return the cursor of the screen.
372372
373-
The default implementation returns 0.
373+
The default implementation returns \nullptr.
374374
*/
375375
QPlatformCursor *QPlatformScreen::cursor() const
376376
{

src/gui/kernel/qwindow.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2644,7 +2644,7 @@ QOpenGLContext *QWindowPrivate::shareContext() const
26442644
native window, or to embed a native window inside a QWindow.
26452645
26462646
If foreign windows are not supported or embedding the native window
2647-
failed in the platform plugin, this function returns 0.
2647+
failed in the platform plugin, this function returns \nullptr.
26482648
26492649
\note The resulting QWindow should not be used to manipulate the underlying
26502650
native window (besides re-parenting), or to observe state changes of the

src/gui/painting/qpaintengine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ void QPaintEngine::setPaintDevice(QPaintDevice *device)
913913

914914
/*!
915915
Returns the device that this engine is painting on, if painting is
916-
active; otherwise returns 0.
916+
active; otherwise returns \nullptr.
917917
*/
918918
QPaintDevice *QPaintEngine::paintDevice() const
919919
{

src/gui/text/qtextcursor.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2116,7 +2116,7 @@ QTextList *QTextCursor::createList(QTextListFormat::Style style)
21162116

21172117
/*!
21182118
Returns the current list if the cursor position() is inside a
2119-
block that is part of a list; otherwise returns 0.
2119+
block that is part of a list; otherwise returns \nullptr.
21202120
21212121
\sa insertList(), createList()
21222122
*/
@@ -2176,7 +2176,7 @@ QTextTable *QTextCursor::insertTable(int rows, int cols, const QTextTableFormat
21762176

21772177
/*!
21782178
Returns a pointer to the current table if the cursor position()
2179-
is inside a block that is part of a table; otherwise returns 0.
2179+
is inside a block that is part of a table; otherwise returns \nullptr.
21802180
21812181
\sa insertTable()
21822182
*/
@@ -2213,7 +2213,7 @@ QTextFrame *QTextCursor::insertFrame(const QTextFrameFormat &format)
22132213
}
22142214

22152215
/*!
2216-
Returns a pointer to the current frame. Returns 0 if the cursor is invalid.
2216+
Returns a pointer to the current frame. Returns \nullptr if the cursor is invalid.
22172217
22182218
\sa insertFrame()
22192219
*/

src/gui/text/qtextobject.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ const QTextDocument *QTextBlock::document() const
13011301

13021302
/*!
13031303
If the block represents a list item, returns the list that the item belongs
1304-
to; otherwise returns 0.
1304+
to; otherwise returns \nullptr.
13051305
*/
13061306
QTextList *QTextBlock::textList() const
13071307
{

src/network/access/qftp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2154,7 +2154,7 @@ QFtp::Command QFtp::currentCommand() const
21542154
\internal
21552155
Returns the QIODevice pointer that is used by the FTP command to read data
21562156
from or store data to. If there is no current FTP command being executed or
2157-
if the command does not use an IO device, this function returns 0.
2157+
if the command does not use an IO device, this function returns \nullptr.
21582158
21592159
This function can be used to delete the QIODevice in the slot connected to
21602160
the commandFinished() signal.

src/network/access/qnetworkrequest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ void QNetworkRequest::setOriginatingObject(QObject *object)
714714
\since 4.6
715715
716716
Returns a reference to the object that initiated this
717-
network request; returns 0 if not set or the object has
717+
network request; returns \nullptr if not set or the object has
718718
been destroyed.
719719
720720
\sa setOriginatingObject()

src/testlib/qtestcase.qdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@
959959
\overload
960960
\since 5.8
961961

962-
Returns a string containing \c{nullptr}.
962+
Returns a string containing \nullptr.
963963
*/
964964

965965
/*!

src/widgets/dialogs/qdialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ Qt::Orientation QDialog::orientation() const
969969
970970
Sets the widget, \a extension, to be the dialog's extension,
971971
deleting any previous extension. The dialog takes ownership of the
972-
extension. Note that if 0 is passed any existing extension will be
972+
extension. Note that if \nullptr is passed, any existing extension will be
973973
deleted. This function must only be called while the dialog is hidden.
974974
975975
Instead of using this functionality, we recommend that you simply call

src/widgets/dialogs/qprogressdialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ void QProgressDialog::setLabelText(const QString &text)
397397
Sets the cancel button to the push button, \a cancelButton. The
398398
progress dialog takes ownership of this button which will be deleted
399399
when necessary, so do not pass the address of an object that is on
400-
the stack, i.e. use new() to create the button. If 0 is passed then
400+
the stack, i.e. use new() to create the button. If \nullptr is passed,
401401
no cancel button will be shown.
402402
403403
\sa setCancelButtonText()

src/widgets/effects/qgraphicseffect.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const
178178

179179
/*!
180180
Returns a pointer to the item if this source is a QGraphicsItem; otherwise
181-
returns 0.
181+
returns \nullptr.
182182
183183
\sa widget()
184184
*/
@@ -189,7 +189,7 @@ const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const
189189

190190
/*!
191191
Returns a pointer to the widget if this source is a QWidget; otherwise
192-
returns 0.
192+
returns \nullptr.
193193
194194
\sa graphicsItem()
195195
*/
@@ -200,7 +200,7 @@ const QWidget *QGraphicsEffectSource::widget() const
200200

201201
/*!
202202
Returns a pointer to the style options (used when drawing the source) if
203-
available; otherwise returns 0.
203+
available; otherwise returns \nullptr.
204204
205205
\sa graphicsItem(), widget()
206206
*/

src/widgets/graphicsview/qgraphicsitem.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1726,8 +1726,8 @@ QGraphicsItem *QGraphicsItem::topLevelItem() const
17261726
/*!
17271727
\since 4.6
17281728

1729-
Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item
1730-
is not a QGraphicsObject.
1729+
Returns a pointer to the item's parent, cast to a QGraphicsObject. Returns
1730+
\nullptr if the parent item is not a QGraphicsObject.
17311731

17321732
\sa parentItem(), childItems()
17331733
*/

src/widgets/graphicsview/qgraphicslayoutitem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ bool QGraphicsLayoutItemPrivate::hasWidthForHeight() const
369369
protected constructor, or by calling setParentLayoutItem(). The
370370
parentLayoutItem() function returns a pointer to the item's layoutItem
371371
parent. If the item's parent is 0 or if the parent does not inherit
372-
from QGraphicsItem, the parentLayoutItem() function then returns 0.
372+
from QGraphicsItem, the parentLayoutItem() function then returns \nullptr.
373373
isLayout() returns \c true if the QGraphicsLayoutItem subclass is itself a
374374
layout, or false otherwise.
375375

src/widgets/itemviews/qabstractitemdelegate.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ QAbstractItemDelegate::~QAbstractItemDelegate()
240240
model being used. The editor's parent widget is specified by \a parent,
241241
and the item options by \a option.
242242
243-
The base implementation returns 0. If you want custom editing you
243+
The base implementation returns \nullptr. If you want custom editing you
244244
will need to reimplement this function.
245245
246246
The returned editor widget should have Qt::StrongFocus;

src/widgets/itemviews/qlistwidget.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ void QListWidget::setSelectionModel(QItemSelectionModel *selectionModel)
13751375

13761376
/*!
13771377
Returns the item that occupies the given \a row in the list if one has been
1378-
set; otherwise returns 0.
1378+
set; otherwise returns \nullptr.
13791379
13801380
\sa row()
13811381
*/
@@ -1442,7 +1442,7 @@ void QListWidget::insertItems(int row, const QStringList &labels)
14421442

14431443
/*!
14441444
Removes and returns the item from the given \a row in the list widget;
1445-
otherwise returns 0.
1445+
otherwise returns \nullptr.
14461446
14471447
Items removed from a list widget will not be managed by Qt, and will need
14481448
to be deleted manually.

0 commit comments

Comments
 (0)