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 <cristian.maureira-fredes@qt.io>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
This commit is contained in:
Friedemann Kleint 2019-01-10 08:46:52 +01:00
parent 574b56913f
commit 3eac688ec0
36 changed files with 62 additions and 61 deletions

View File

@ -14,6 +14,7 @@ macro.macos = "macOS"
macro.menu = "\\b"
macro.oslash.HTML = "&oslash;"
macro.ouml.HTML = "&ouml;"
macro.nullptr = "\\c{nullptr}"
macro.QA = "\\e{Qt Assistant}"
macro.QD = "\\e{Qt Designer}"
macro.QL = "\\e{Qt Linguist}"

View File

@ -654,7 +654,7 @@ void QAccessible::removeActivationObserver(ActivationObserver *observer)
/*!
If a QAccessibleInterface implementation exists for the given \a object,
this function returns a pointer to the implementation; otherwise it
returns 0.
returns \nullptr.
The function calls all installed factory functions (from most
recently installed to least recently installed) until one is found
@ -770,7 +770,7 @@ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
/*!
Returns the QAccessibleInterface belonging to the \a id.
Returns 0 if the id is invalid.
Returns \nullptr if the id is invalid.
*/
QAccessibleInterface *QAccessible::accessibleInterface(Id id)
{
@ -1119,7 +1119,7 @@ QAccessibleInterface *QAccessibleInterface::focusChild() const
\fn QAccessibleInterface *QAccessibleInterface::childAt(int x, int y) const
Returns the QAccessibleInterface of a child that contains the screen coordinates (\a x, \a y).
If there are no children at this position this function returns 0.
If there are no children at this position this function returns \nullptr.
The returned accessible must be a child, but not necessarily a direct child.
This function is only relyable for visible objects (invisible
@ -1139,7 +1139,7 @@ QAccessibleInterface *QAccessibleInterface::focusChild() const
Returns the QAccessibleInterface of the parent in the accessible object hierarchy.
Returns 0 if no parent exists (e.g. for the top level application object).
Returns \nullptr if no parent exists (e.g. for the top level application object).
\sa child()
*/
@ -1150,7 +1150,7 @@ QAccessibleInterface *QAccessibleInterface::focusChild() const
Returns the accessible child with index \a index.
0-based index. The number of children of an object can be checked with childCount.
Returns 0 when asking for an invalid child (e.g. when the child became invalid in the meantime).
Returns \nullptr when asking for an invalid child (e.g. when the child became invalid in the meantime).
\sa childCount(), parent()
*/
@ -1356,7 +1356,7 @@ QAccessibleEvent::~QAccessibleEvent()
\internal
Returns the uniqueId of the QAccessibleInterface represented by this event.
In case the object() function returns 0 this is the only way to access the
In case the object() function returns \nullptr, this is the only way to access the
interface.
*/
QAccessible::Id QAccessibleEvent::uniqueId() const
@ -1786,7 +1786,7 @@ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const
(This means that at least one interface among the ancestors should
return a valid QWindow pointer).
The default implementation returns 0.
The default implementation returns \nullptr.
*/
QWindow *QAccessibleInterface::window() const
{

View File

@ -113,7 +113,7 @@ QImageData::QImageData()
\internal
Creates a new image data.
Returns 0 if invalid parameters are give or anything else failed.
Returns \nullptr if invalid parameters are give or anything else failed.
*/
QImageData * QImageData::create(const QSize &size, QImage::Format format)
{

View File

@ -879,8 +879,8 @@ QStandardItem::~QStandardItem()
}
/*!
Returns the item's parent item, or 0 if the item has no parent.
\note For toplevel items parent() returns 0. To receive toplevel
Returns the item's parent item, or \nullptr if the item has no parent.
\note For toplevel items parent() returns \nullptr. To receive toplevel
item's parent use QStandardItemModel::invisibleRootItem() instead.
\sa child(), QStandardItemModel::invisibleRootItem()
@ -1548,7 +1548,7 @@ QModelIndex QStandardItem::index() const
Returns the QStandardItemModel that this item belongs to.
If the item is not a child of another item that belongs to the model, this
function returns 0.
function returns \nullptr.
\sa index()
*/
@ -1865,7 +1865,7 @@ void QStandardItem::setChild(int row, int column, QStandardItem *item)
/*!
Returns the child item at (\a row, \a column) if one has been set; otherwise
returns 0.
returns \nullptr.
\sa setChild(), takeChild(), parent()
*/
@ -1881,7 +1881,7 @@ QStandardItem *QStandardItem::child(int row, int column) const
/*!
Removes the child item at (\a row, \a column) without deleting it, and returns
a pointer to the item. If there was no child at the given location, then
this function returns 0.
this function returns \nullptr.
Note that this function, unlike takeRow() and takeColumn(), does not affect
the dimensions of the child table.
@ -2283,7 +2283,7 @@ void QStandardItemModel::clear()
itemPrototype()), and set it in the parent item's child table, if no item
already exists at that index.
If \a index is an invalid index, this function returns 0.
If \a index is an invalid index, this function returns \nullptr.
\sa indexFromItem()
*/
@ -2380,7 +2380,7 @@ void QStandardItemModel::setItem(int row, int column, QStandardItem *item)
\since 4.2
Returns the item for the given \a row and \a column if one has been set;
otherwise returns 0.
otherwise returns \nullptr.
\sa setItem(), takeItem(), itemFromIndex()
*/
@ -2453,7 +2453,7 @@ void QStandardItemModel::setHorizontalHeaderItem(int column, QStandardItem *item
\since 4.2
Returns the horizontal header item for \a column if one has been set;
otherwise returns 0.
otherwise returns \nullptr.
\sa setHorizontalHeaderItem(), verticalHeaderItem()
*/
@ -2509,7 +2509,7 @@ void QStandardItemModel::setVerticalHeaderItem(int row, QStandardItem *item)
\since 4.2
Returns the vertical header item for row \a row if one has been set;
otherwise returns 0.
otherwise returns \nullptr.
\sa setVerticalHeaderItem(), horizontalHeaderItem()
*/

View File

@ -3072,7 +3072,7 @@ QDropEvent::~QDropEvent()
/*!
If the source of the drag operation is a widget in this
application, this function returns that source; otherwise it
returns 0. The source of the operation is the first parameter to
returns \nullptr. The source of the operation is the first parameter to
the QDrag object used instantiate the drag.
This is useful if your widget needs special behavior when dragging
@ -3514,7 +3514,7 @@ QActionEvent::~QActionEvent()
\fn QAction *QActionEvent::before() const
If type() is \l ActionAdded, returns the action that should
appear before action(). If this function returns 0, the action
appear before action(). If this function returns \nullptr, the action
should be appended to already existing actions on the same
widget.

View File

@ -3747,7 +3747,7 @@ Qt::LayoutDirection QGuiApplication::layoutDirection()
Returns the active application override cursor.
This function returns 0 if no application cursor has been defined (i.e. the
This function returns \nullptr if no application cursor has been defined (i.e. the
internal cursor stack is empty).
\sa setOverrideCursor(), restoreOverrideCursor()

View File

@ -1118,7 +1118,7 @@ void QOpenGLContext::swapBuffers(QSurface *surface)
/*!
Resolves the function pointer to an OpenGL extension function, identified by \a procName
Returns 0 if no such function can be found.
Returns \nullptr if no such function can be found.
*/
QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName) const
{

View File

@ -84,7 +84,7 @@ QT_BEGIN_NAMESPACE
\a windowCursor is a pointer to the QCursor that should be displayed.
To unset the cursor of \a window, 0 is passed. This means \a window does not have
To unset the cursor of \a window, \nullptr is passed. This means \a window does not have
a cursor set and the cursor of a the first parent window which has a cursor explicitly
set or the system default cursor should take effect.

View File

@ -350,7 +350,7 @@ void QPlatformIntegration::destroy()
/*!
Returns the platforms input context.
The default implementation returns 0, implying no input method support.
The default implementation returns \nullptr, implying no input method support.
*/
QPlatformInputContext *QPlatformIntegration::inputContext() const
{

View File

@ -370,7 +370,7 @@ QString QPlatformScreen::serialNumber() const
/*!
Reimplement this function in subclass to return the cursor of the screen.
The default implementation returns 0.
The default implementation returns \nullptr.
*/
QPlatformCursor *QPlatformScreen::cursor() const
{

View File

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

View File

@ -913,7 +913,7 @@ void QPaintEngine::setPaintDevice(QPaintDevice *device)
/*!
Returns the device that this engine is painting on, if painting is
active; otherwise returns 0.
active; otherwise returns \nullptr.
*/
QPaintDevice *QPaintEngine::paintDevice() const
{

View File

@ -2116,7 +2116,7 @@ QTextList *QTextCursor::createList(QTextListFormat::Style style)
/*!
Returns the current list if the cursor position() is inside a
block that is part of a list; otherwise returns 0.
block that is part of a list; otherwise returns \nullptr.
\sa insertList(), createList()
*/
@ -2176,7 +2176,7 @@ QTextTable *QTextCursor::insertTable(int rows, int cols, const QTextTableFormat
/*!
Returns a pointer to the current table if the cursor position()
is inside a block that is part of a table; otherwise returns 0.
is inside a block that is part of a table; otherwise returns \nullptr.
\sa insertTable()
*/
@ -2213,7 +2213,7 @@ QTextFrame *QTextCursor::insertFrame(const QTextFrameFormat &format)
}
/*!
Returns a pointer to the current frame. Returns 0 if the cursor is invalid.
Returns a pointer to the current frame. Returns \nullptr if the cursor is invalid.
\sa insertFrame()
*/

View File

@ -1301,7 +1301,7 @@ const QTextDocument *QTextBlock::document() const
/*!
If the block represents a list item, returns the list that the item belongs
to; otherwise returns 0.
to; otherwise returns \nullptr.
*/
QTextList *QTextBlock::textList() const
{

View File

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

View File

@ -714,7 +714,7 @@ void QNetworkRequest::setOriginatingObject(QObject *object)
\since 4.6
Returns a reference to the object that initiated this
network request; returns 0 if not set or the object has
network request; returns \nullptr if not set or the object has
been destroyed.
\sa setOriginatingObject()

View File

@ -959,7 +959,7 @@
\overload
\since 5.8
Returns a string containing \c{nullptr}.
Returns a string containing \nullptr.
*/
/*!

View File

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

View File

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

View File

@ -178,7 +178,7 @@ QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const
/*!
Returns a pointer to the item if this source is a QGraphicsItem; otherwise
returns 0.
returns \nullptr.
\sa widget()
*/
@ -189,7 +189,7 @@ const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const
/*!
Returns a pointer to the widget if this source is a QWidget; otherwise
returns 0.
returns \nullptr.
\sa graphicsItem()
*/
@ -200,7 +200,7 @@ const QWidget *QGraphicsEffectSource::widget() const
/*!
Returns a pointer to the style options (used when drawing the source) if
available; otherwise returns 0.
available; otherwise returns \nullptr.
\sa graphicsItem(), widget()
*/

View File

@ -1726,8 +1726,8 @@ QGraphicsItem *QGraphicsItem::topLevelItem() const
/*!
\since 4.6
Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item
is not a QGraphicsObject.
Returns a pointer to the item's parent, cast to a QGraphicsObject. Returns
\nullptr if the parent item is not a QGraphicsObject.
\sa parentItem(), childItems()
*/

View File

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

View File

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

View File

@ -1375,7 +1375,7 @@ void QListWidget::setSelectionModel(QItemSelectionModel *selectionModel)
/*!
Returns the item that occupies the given \a row in the list if one has been
set; otherwise returns 0.
set; otherwise returns \nullptr.
\sa row()
*/
@ -1442,7 +1442,7 @@ void QListWidget::insertItems(int row, const QStringList &labels)
/*!
Removes and returns the item from the given \a row in the list widget;
otherwise returns 0.
otherwise returns \nullptr.
Items removed from a list widget will not be managed by Qt, and will need
to be deleted manually.

View File

@ -1936,7 +1936,7 @@ int QTableWidget::column(const QTableWidgetItem *item) const
/*!
Returns the item for the given \a row and \a column if one has been set; otherwise
returns 0.
returns \nullptr.
\sa setItem()
*/
@ -2029,7 +2029,7 @@ QTableWidgetItem *QTableWidget::takeVerticalHeaderItem(int row)
/*!
Returns the horizontal header item for column, \a column, if one has been
set; otherwise returns 0.
set; otherwise returns \nullptr.
*/
QTableWidgetItem *QTableWidget::horizontalHeaderItem(int column) const
{
@ -2435,7 +2435,7 @@ int QTableWidget::visualColumn(int logicalColumn) const
/*!
\fn QTableWidgetItem *QTableWidget::itemAt(const QPoint &point) const
Returns a pointer to the item at the given \a point, or returns 0 if
Returns a pointer to the item at the given \a point, or returns \nullptr if
\a point is not covered by an item in the table widget.
\sa item()

View File

@ -2688,7 +2688,7 @@ void QTreeWidget::addTopLevelItem(QTreeWidgetItem *item)
/*!
Removes the top-level item at the given \a index in the tree and
returns it, otherwise returns 0;
returns it, otherwise returns \nullptr;
\sa insertTopLevelItem(), topLevelItem(), topLevelItemCount()
*/

View File

@ -360,7 +360,7 @@ void QApplicationPrivate::createEventDispatcher()
/*!
\fn QWidget *QApplication::topLevelAt(const QPoint &point)
Returns the top-level widget at the given \a point; returns 0 if
Returns the top-level widget at the given \a point; returns \nullptr if
there is no such widget.
*/
QWidget *QApplication::topLevelAt(const QPoint &pos)
@ -1226,7 +1226,7 @@ void QApplication::setStyle(QStyle *style)
"windows", "windowsvista", "fusion", or "macintosh". Style
names are case insensitive.
Returns 0 if an unknown \a style is passed, otherwise the QStyle object
Returns \nullptr if an unknown \a style is passed, otherwise the QStyle object
returned is set as the application's GUI style.
\warning To ensure that the application's style is set correctly, it is
@ -2177,7 +2177,7 @@ void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous)
/*!internal
* Helper function that returns the new focus widget, but does not set the focus reason.
* Returns 0 if a new focus widget could not be found.
* Returns \nullptr if a new focus widget could not be found.
* Shared with QGraphicsProxyWidgetPrivate::findFocusChild()
*/
QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next,

View File

@ -1825,7 +1825,7 @@ int QFormLayout::rowCount() const
/*!
Returns the layout item in the given \a row with the specified \a
role (column). Returns 0 if there is no such item.
role (column). Returns \nullptr if there is no such item.
\sa QLayout::itemAt(), setItem()
*/

View File

@ -10409,7 +10409,7 @@ bool QWidget::hasHeightForWidth() const
Returns the visible child widget at the position (\a{x}, \a{y})
in the widget's coordinate system. If there is no visible child
widget at the specified position, the function returns 0.
widget at the specified position, the function returns \nullptr.
*/
/*!
@ -12373,7 +12373,7 @@ Q_WIDGETS_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget)
\since 4.5
Returns the proxy widget for the corresponding embedded widget in a graphics
view; otherwise returns 0.
view; otherwise returns \nullptr.
\sa QGraphicsProxyWidget::createProxyForChildWidget(),
QGraphicsScene::addWidget()

View File

@ -77,7 +77,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
/*!
Creates and returns a QStyle object that matches the given \a key, or
returns 0 if no matching style is found.
returns \nullptr if no matching style is found.
Both built-in styles and styles from style plugins are queried for a
matching style.

View File

@ -242,7 +242,7 @@ void QUndoGroup::setActiveStack(QUndoStack *stack)
Returns the active stack of this group.
If none of the stacks are active, or if the group is empty, this function
returns 0.
returns \nullptr.
\sa setActiveStack(), QUndoStack::setActive()
*/

View File

@ -412,7 +412,7 @@ void QUndoView::setGroup(QUndoGroup *group)
/*!
Returns the group displayed by this view.
If the view is not looking at group, this function returns 0.
If the view is not looking at group, this function returns \nullptr.
\sa setGroup(), setStack()
*/

View File

@ -805,7 +805,7 @@ bool QAbstractButton::autoExclusive() const
Returns the group that this button belongs to.
If the button is not a member of any QButtonGroup, this function
returns 0.
returns \nullptr.
\sa QButtonGroup
*/

View File

@ -692,7 +692,7 @@ QLineEdit *QAbstractSpinBox::lineEdit() const
QAbstractSpinBox takes ownership of the new lineEdit
If QLineEdit::validator() for the \a lineEdit returns 0, the internal
If QLineEdit::validator() for the \a lineEdit returns \nullptr, the internal
validator of the spinbox will be set on the line edit.
*/

View File

@ -2283,7 +2283,7 @@ int QMenu::columnCount() const
}
/*!
Returns the item at \a pt; returns 0 if there is no item there.
Returns the item at \a pt; returns \nullptr if there is no item there.
*/
QAction *QMenu::actionAt(const QPoint &pt) const
{

View File

@ -1581,7 +1581,7 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event)
}
/*!
Returns the QAction at \a pt. Returns 0 if there is no action at \a pt or if
Returns the QAction at \a pt. Returns \nullptr if there is no action at \a pt or if
the location has a separator.
\sa addAction(), addSeparator()