Merge remote-tracking branch 'origin/5.13' into dev

Change-Id: Ib5fe71da1839be07c1df713b079866a061cee9e5
bb10
Qt Forward Merge Bot 2019-02-06 23:13:28 +01:00
commit 5dd09b75cb
114 changed files with 679 additions and 553 deletions

View File

@ -185,7 +185,9 @@ void MainWindow::find()
m_findMatches.clear();
m_findIndex = 0;
foreach (const QStandardItem *item, m_model->findItems(value, Qt::MatchContains | Qt::MatchFixedString | Qt::MatchRecursive))
const QList<QStandardItem *> items =
m_model->findItems(value, Qt::MatchContains | Qt::MatchFixedString | Qt::MatchRecursive);
for (const QStandardItem *item : items)
m_findMatches.append(m_model->indexFromItem(item));
statusBar()->showMessage(tr("%n mime types match \"%1\".", 0, m_findMatches.size()).arg(value));
updateFindActions();

View File

@ -185,7 +185,7 @@ void Game::write(QJsonObject &json) const
json["player"] = playerObject;
QJsonArray levelArray;
foreach (const Level level, mLevels) {
for (const Level level : mLevels) {
QJsonObject levelObject;
level.write(levelObject);
levelArray.append(levelObject);

View File

@ -97,7 +97,7 @@ void Level::write(QJsonObject &json) const
{
json["name"] = mName;
QJsonArray npcArray;
foreach (const Character npc, mNpcs) {
for (const Character npc : mNpcs) {
QJsonObject npcObject;
npc.write(npcObject);
npcArray.append(npcObject);

View File

@ -89,9 +89,10 @@ Window::Window()
void Window::loadImage()
{
QStringList formats;
foreach (QByteArray format, QImageReader::supportedImageFormats())
const QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
for (const QByteArray &format : supportedFormats)
if (format.toLower() == format)
formats.append("*." + format);
formats.append(QLatin1String("*.") + QString::fromLatin1(format));
QString newPath = QFileDialog::getOpenFileName(this, tr("Open Image"),
path, tr("Image files (%1)").arg(formats.join(' ')));

View File

@ -62,7 +62,8 @@ void method1()
qDebug() << "Error:" << reply.error().message();
exit(1);
}
foreach (QString name, reply.value())
const QStringList values = reply.value();
for (const QString &name : values)
qDebug() << name;
}

View File

@ -162,7 +162,6 @@ void SlippyMap::handleNetworkData(QNetworkReply *reply)
{
QImage img;
QPoint tp = reply->request().attribute(QNetworkRequest::User).toPoint();
QUrl url = reply->url();
if (!reply->error())
if (!img.load(reply, 0))
img = QImage();
@ -173,10 +172,12 @@ void SlippyMap::handleNetworkData(QNetworkReply *reply)
emit updated(tileRect(tp));
// purge unused spaces
QRect bound = m_tilesRect.adjusted(-2, -2, 2, 2);
foreach(QPoint tp, m_tilePixmaps.keys())
if (!bound.contains(tp))
m_tilePixmaps.remove(tp);
const QRect bound = m_tilesRect.adjusted(-2, -2, 2, 2);
for (auto it = m_tilePixmaps.keyBegin(); it != m_tilePixmaps.keyEnd(); ++it) {
const QPoint &tp = *it;
if (!bound.contains(tp))
m_tilePixmaps.remove(tp);
}
download();
}

View File

@ -387,7 +387,7 @@ void Widget::renderWindowReady()
QList<QByteArray> extensionList = context->extensions().toList();
std::sort(extensionList.begin(), extensionList.end());
m_extensions->append(tr("Found %1 extensions:").arg(extensionList.count()));
Q_FOREACH (const QByteArray &ext, extensionList)
for (const QByteArray &ext : qAsConst(extensionList))
m_extensions->append(QString::fromLatin1(ext));
m_output->moveCursor(QTextCursor::Start);

View File

@ -201,7 +201,7 @@ void GLWidget::paintEvent(QPaintEvent *event)
//! [10]
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
foreach (Bubble *bubble, bubbles) {
for (Bubble *bubble : qAsConst(bubbles)) {
if (bubble->rect().intersects(event->rect()))
bubble->drawBubble(&painter);
}

View File

@ -385,10 +385,10 @@ void GLWidget::paintGL()
painter.endNativePainting();
if (m_showBubbles)
foreach (Bubble *bubble, m_bubbles) {
if (m_showBubbles) {
for (Bubble *bubble : qAsConst(m_bubbles))
bubble->drawBubble(&painter);
}
}
if (const int elapsed = m_time.elapsed()) {
QString framesPerSecond;

View File

@ -176,7 +176,7 @@ void MainWindow::timerUsageChanged(bool enabled)
m_timer->start();
} else {
m_timer->stop();
foreach (QOpenGLWidget *w, m_glWidgets)
for (QOpenGLWidget *w : qAsConst(m_glWidgets))
w->update();
}
}

View File

@ -79,9 +79,9 @@ int main(int argc, char **argv)
// create one window on each additional screen as well
QList<QScreen *> screens = app.screens();
QList<WindowPtr> windows;
foreach (QScreen *screen, screens) {
const QList<QScreen *> screens = app.screens();
for (QScreen *screen : screens) {
if (screen == app.primaryScreen())
continue;
WindowPtr window(new Window(screen));

View File

@ -61,10 +61,10 @@
QPixmap cached(const QString &img)
{
if (QPixmap *p = QPixmapCache::find(img))
return *p;
QPixmap pm;
if (QPixmapCache::find(img, &pm))
return pm;
pm = QPixmap::fromImage(QImage(img), Qt::OrderedDither | Qt::OrderedAlphaDither);
if (pm.isNull())
return QPixmap();

View File

@ -50,7 +50,8 @@
#include <QtCore>
void parseHtmlFile(QTextStream &out, const QString &fileName) {
void parseHtmlFile(QTextStream &out, const QString &fileName)
{
QFile file(fileName);
out << "Analysis of HTML file: " << fileName << endl;
@ -71,11 +72,11 @@ void parseHtmlFile(QTextStream &out, const QString &fileName) {
while (!reader.atEnd()) {
reader.readNext();
if (reader.isStartElement()) {
if (reader.name() == "title")
if (reader.name() == QLatin1String("title"))
title = reader.readElementText();
else if(reader.name() == "a")
links.append(reader.attributes().value("href").toString());
else if(reader.name() == "p")
else if (reader.name() == QLatin1String("a"))
links.append(reader.attributes().value(QLatin1String("href")).toString());
else if (reader.name() == QLatin1String("p"))
++paragraphCount;
}
}
@ -94,10 +95,10 @@ void parseHtmlFile(QTextStream &out, const QString &fileName) {
<< " Number of links: " << links.size() << endl
<< " Showing first few links:" << endl;
while(links.size() > 5)
while (links.size() > 5)
links.removeLast();
foreach(QString link, links)
for (const QString &link : qAsConst(links))
out << " " << link << endl;
out << endl << endl;
}
@ -108,11 +109,10 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv);
// get a list of all html files in the current directory
QStringList filter;
filter << "*.htm";
filter << "*.html";
const QStringList filter = { QStringLiteral("*.htm"),
QStringLiteral("*.html") };
QStringList htmlFiles = QDir(":/").entryList(filter, QDir::Files);
const QStringList htmlFiles = QDir(QStringLiteral(":/")).entryList(filter, QDir::Files);
QTextStream out(stdout);
@ -122,8 +122,8 @@ int main(int argc, char **argv)
}
// parse each html file and write the result to file/stream
foreach(QString file, htmlFiles)
parseHtmlFile(out, ":/" + file);
for (const QString &file : htmlFiles)
parseHtmlFile(out, QStringLiteral(":/") + file);
return 0;
}

View File

@ -345,14 +345,10 @@ ProjectGenerator::writeMakefile(QTextStream &t)
<< getWritableVar("CONFIG_REMOVE", false)
<< getWritableVar("INCLUDEPATH") << endl;
t << "# The following define makes your compiler warn you if you use any\n"
"# feature of Qt which has been marked as deprecated (the exact warnings\n"
"# depend on your compiler). Please consult the documentation of the\n"
"# deprecated API in order to know how to port your code away from it.\n"
"DEFINES += QT_DEPRECATED_WARNINGS\n"
"\n"
"# You can also make your code fail to compile if you use deprecated APIs.\n"
t << "# You can make your code fail to compile if you use deprecated APIs.\n"
"# In order to do so, uncomment the following line.\n"
"# Please consult the documentation of the deprecated API in order to know\n"
"# how to port your code away from it.\n"
"# You can also select to disable deprecated APIs only up to a certain version of Qt.\n"
"#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0\n\n";

View File

@ -773,6 +773,7 @@ QAnimationDriver::~QAnimationDriver()
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
Sets the time at which an animation driver should start at.
@ -799,6 +800,7 @@ qint64 QAnimationDriver::startTime() const
{
return 0;
}
#endif
/*!

View File

@ -147,9 +147,10 @@ public:
virtual qint64 elapsed() const;
// ### Qt6: Remove these two functions
void setStartTime(qint64 startTime);
qint64 startTime() const;
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED void setStartTime(qint64 startTime);
QT_DEPRECATED qint64 startTime() const;
#endif
Q_SIGNALS:
void started();

View File

@ -1979,11 +1979,11 @@ bool qSharedBuild() Q_DECL_NOTHROW
a specified version of Qt or any earlier version. The default version number is 5.0,
meaning that functions deprecated in or before Qt 5.0 will not be included.
Examples:
When using a future release of Qt 5, set QT_DISABLE_DEPRECATED_BEFORE=0x050100 to
disable functions deprecated in Qt 5.1 and earlier. In any release, set
QT_DISABLE_DEPRECATED_BEFORE=0x000000 to enable any functions, including the ones
deprecated in Qt 5.0
For instance, when using a future release of Qt 5, set
\c{QT_DISABLE_DEPRECATED_BEFORE=0x050100} to disable functions deprecated in
Qt 5.1 and earlier. In any release, set
\c{QT_DISABLE_DEPRECATED_BEFORE=0x000000} to enable all functions, including
the ones deprecated in Qt 5.0.
\sa QT_DEPRECATED_WARNINGS
*/
@ -1993,12 +1993,24 @@ bool qSharedBuild() Q_DECL_NOTHROW
\macro QT_DEPRECATED_WARNINGS
\relates <QtGlobal>
If this macro is defined, the compiler will generate warnings if API declared as
Since Qt 5.13, this macro has no effect. In Qt 5.12 and before, if this macro
is defined, the compiler will generate warnings if any API declared as
deprecated by Qt is used.
\sa QT_DISABLE_DEPRECATED_BEFORE
\sa QT_DISABLE_DEPRECATED_BEFORE, QT_NO_DEPRECATED_WARNINGS
*/
/*!
\macro QT_NO_DEPRECATED_WARNINGS
\relates <QtGlobal>
\since 5.13
This macro can be used to suppress deprecation warnings that would otherwise
be generated when using deprecated APIs.
\sa QT_DISABLE_DEPRECATED_BEFORE
*/
#if defined(QT_BUILD_QMAKE)
// needed to bootstrap qmake
static const unsigned int qt_one = 1;

View File

@ -287,7 +287,7 @@ typedef double qreal;
# undef QT_DEPRECATED_X
# undef QT_DEPRECATED_VARIABLE
# undef QT_DEPRECATED_CONSTRUCTOR
#elif defined(QT_DEPRECATED_WARNINGS)
#elif !defined(QT_NO_DEPRECATED_WARNINGS)
# undef QT_DEPRECATED
# define QT_DEPRECATED Q_DECL_DEPRECATED
# undef QT_DEPRECATED_X

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "clipwindow.h"
@ -67,10 +67,11 @@ ClipWindow::ClipWindow(QWidget *parent)
previousItems = new QListWidget(centralWidget);
//! [0]
connect(clipboard, SIGNAL(dataChanged()), this, SLOT(updateClipboard()));
connect(clipboard, &QClipboard::dataChanged,
this, &ClipWindow::updateClipboard);
//! [0]
connect(mimeTypeCombo, SIGNAL(activated(QString)),
this, SLOT(updateData(QString)));
connect(mimeTypeCombo, QOverload<QString>::of(&QComboBox::activated),
this, &ClipWindow::updateData);
QVBoxLayout *currentLayout = new QVBoxLayout(currentItem);
currentLayout->addWidget(mimeTypeLabel);

View File

@ -73,8 +73,8 @@ for (int i = 0; i < 4; ++i) {
//! [2]
QTreeView *treeView = new QTreeView(this);
treeView->setModel(myStandardItemModel);
connect(treeView, SIGNAL(clicked(QModelIndex)),
this, SLOT(clicked(QModelIndex)));
connect(treeView, &QTreeView::clicked,
this, &MyWidget::clicked);
//! [2]

View File

@ -64,7 +64,8 @@ MyMainWidget::MyMainWidget(QWidget *parent)
:QWidget(parent)
{
QGuiApplication::setFallbackSessionManagementEnabled(false);
connect(qApp, SIGNAL(commitDataRequest(QSessionManager)), SLOT(commitData(QSessionManager)));
connect(qApp, &QGuiApplication::commitDataRequest,
this, &MyMainWidget::commitData);
}
void MyMainWidget::commitData(QSessionManager& manager)
@ -102,12 +103,14 @@ appname -session id
//! [3]
foreach (const QString &command, mySession.restartCommand())
const QStringList commands = mySession.restartCommand();
for (const QString &command : commands)
do_something(command);
//! [3]
//! [4]
foreach (const QString &command, mySession.discardCommand())
const QStringList commands = mySession.discardCommand();
for (const QString &command : mySession.discardCommand())
do_something(command);
//! [4]

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "dragwidget.h"
#include "mainwindow.h"
@ -64,10 +64,10 @@ MainWindow::MainWindow(QWidget *parent)
QLabel *dataLabel = new QLabel(tr("Amount of data (bytes):"), centralWidget);
dragWidget = new DragWidget(centralWidget);
connect(dragWidget, SIGNAL(mimeTypes(QStringList)),
this, SLOT(setMimeTypes(QStringList)));
connect(dragWidget, SIGNAL(dragResult(QString)),
this, SLOT(setDragResult(QString)));
connect(dragWidget, &DragWidget::mimeTypes,
this, &MainWindow::setMimeTypes);
connect(dragWidget, &DragWidget:dragResult,
this, &MainWindow::setDragResult);
QVBoxLayout *mainLayout = new QVBoxLayout(centralWidget);
mainLayout->addWidget(mimeTypeLabel);

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
void myProcessing(const QString &)
{
@ -85,8 +85,8 @@ int main()
{
// FORMATS
//! [2]
QStringList list = QPicture::inputFormatList();
foreach (const QString &string, list)
const QStringList list = QPicture::inputFormatList();
for (const QString &string : list)
myProcessing(string);
//! [2]
}
@ -94,8 +94,8 @@ int main()
{
// OUTPUT
//! [3]
QStringList list = QPicture::outputFormatList();
foreach (const QString &string, list)
const QStringList list = QPicture::outputFormatList();
for (const QString &string : list)
myProcessing(string);
//! [3]
}

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
int main(int argc, char **argv)
{
@ -60,16 +60,19 @@ int main(int argc, char **argv)
fontTree.setColumnCount(2);
fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes");
foreach (const QString &family, database.families()) {
const QStringList fontFamilies = database.families();
for (const QString &family : fontFamilies) {
QTreeWidgetItem *familyItem = new QTreeWidgetItem(&fontTree);
familyItem->setText(0, family);
foreach (const QString &style, database.styles(family)) {
const QStringList fontStyles = database.styles(family);
for (const QString &style : fontStyles) {
QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
styleItem->setText(0, style);
QString sizes;
foreach (int points, database.smoothSizes(family, style))
const QList<int> smoothSizes = database.smoothSizes(family, style)
for (int points : smoothSizes)
sizes += QString::number(points) + ' ';
styleItem->setText(1, sizes.trimmed());

View File

@ -105,8 +105,8 @@ ScreenWidget::ScreenWidget(QWidget *parent, QColor initialColor,
//invertButton->setOn(inverted);
invertButton->setEnabled(false);
connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
connect(invertButton, SIGNAL(clicked()), this, SLOT(invertImage()));
connect(colorButton, &QPushButton::clicked, this, &ScreenWidget::setColor);
connect(invertButton, &QPushButton::clicked, this, &ScreenWidget::invertImage);
QGridLayout *gridLayout = new QGridLayout;
gridLayout->addWidget(imageLabel, 0, 0, 1, 2);

View File

@ -58,7 +58,7 @@ A main menu provides entries for selecting files, and adjusting the
brightness of the separations.
*/
#include <QtGui>
#include <QtWidgets>
#include "finalwidget.h"
#include "screenwidget.h"
@ -126,11 +126,11 @@ void Viewer::createMenus()
menuBar()->addMenu(fileMenu);
menuBar()->addMenu(brightnessMenu);
connect(openAction, SIGNAL(triggered()), this, SLOT(chooseFile()));
connect(saveAction, SIGNAL(triggered()), this, SLOT(saveImage()));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(brightnessMenu, SIGNAL(triggered(QAction*)), this,
SLOT(setBrightness(QAction*)));
connect(openAction, &QAction::triggered, this, &Viewer::chooseFile);
connect(saveAction, &QAction::triggered, this, &Viewer::saveImage);
connect(quitAction, &QAction::triggered, qApp, QApplication::quit);
connect(brightnessMenu, &QMenu::triggered,
this, &Viewer::setBrightness);
}
/*
@ -160,9 +160,9 @@ QFrame* Viewer::createCentralWidget()
yellowWidget = new ScreenWidget(frame, Qt::yellow, tr("Yellow"),
ScreenWidget::Yellow, labelSize);
connect(cyanWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
connect(magentaWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
connect(yellowWidget, SIGNAL(imageChanged()), this, SLOT(createImage()));
connect(cyanWidget, &ScreenWidget::imageChanged, this, &Viewer::createImage);
connect(magentaWidget, &ScreenWidget::imageChanged, this, &Viewer::createImage);
connect(yellowWidget, &ScreenWidget::imageChanged, this, &Viewer::createImage);
grid->addWidget(finalWidget, 0, 0, Qt::AlignTop | Qt::AlignHCenter);
grid->addWidget(cyanWidget, 0, 1, Qt::AlignTop | Qt::AlignHCenter);

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
#include "xmlwriter.h"
@ -73,9 +73,9 @@ MainWindow::MainWindow()
editor = new QTextEdit(this);
connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(calendarAction, SIGNAL(triggered()), this, SLOT(insertCalendar()));
connect(saveAction, &QAction::triggered, this, &MainWindow::saveFile);
connect(quitAction, &QAction::triggered, this, &MainWindow::close);
connect(calendarAction, &QAction::triggered, this, &MainWindow::insertCalendar);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Writer"));

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
#include "xmlwriter.h"
@ -75,9 +75,9 @@ MainWindow::MainWindow()
editor = new QTextEdit(this);
//! [0]
connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(calendarAction, SIGNAL(triggered()), this, SLOT(insertCalendar()));
connect(saveAction, &QAction::triggered, this, &MainWindow::saveFile);
connect(quitAction, &QAction::triggered, this, &MainWindow::close);
connect(calendarAction, &QAction::triggered, this, &MainWindow::insertCalendar);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Writer"));

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
#include "xmlwriter.h"
@ -64,7 +64,7 @@ MainWindow::MainWindow()
quitAction->setShortcut(tr("Ctrl+Q"));
menuBar()->addMenu(fileMenu);
editor = new QTextEdit();
editor = new QTextEdit;
QTextCursor cursor(editor->textCursor());
cursor.movePosition(QTextCursor::Start);
@ -130,8 +130,8 @@ MainWindow::MainWindow()
plainCharFormat);
connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(saveAction, &QAction::triggered, this, &MainWindow::saveFile);
connect(quitAction, &QAction::triggered, this, &MainWindow::close);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Frames"));

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
@ -88,7 +88,8 @@ MainWindow::MainWindow()
document = new QTextDocument(this);
editor->setDocument(document);
connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
connect(editor, &QTextEdit::selectionChanged,
this, &MainWindow::updateMenus);
updateMenus();

View File

@ -74,7 +74,7 @@ MainWindow::MainWindow()
document = new QTextDocument(this);
editor->setDocument(document);
connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
connect(editor, &QTextEdit::selectionChanged, this, &MainWindow::updateMenus);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Writer"));

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
@ -90,7 +90,8 @@ MainWindow::MainWindow()
document = new QTextDocument(this);
editor->setDocument(document);
connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
connect(editor, &QTextEdit::selectionChanged,
this, &MainWindow::updateMenus);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Writer"));

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
#include "xmlwriter.h"
@ -132,9 +132,9 @@ MainWindow::MainWindow()
}
//! [8]
connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(showTableAction, SIGNAL(triggered()), this, SLOT(showTable()));
connect(saveAction, &QAction:triggered, this, &MainWindow::saveFile);
connect(quitAction, &QAction:triggered, this, &MainWindow::close);
connect(showTableAction, &QAction:triggered, this, &MainWindow::showTable);
setCentralWidget(editor);
setWindowTitle(tr("Text Document Tables"));

View File

@ -315,9 +315,9 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St
% HexString<uint>(actualSize.height());
if (mode == QIcon::Active) {
if (QPixmapCache::find(key % HexString<uint>(mode), pm))
if (QPixmapCache::find(key % HexString<uint>(mode), &pm))
return pm; // horray
if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) {
if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), &pm)) {
QPixmap active = pm;
if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>(qApp))
active = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(QIcon::Active, pm);
@ -326,7 +326,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St
}
}
if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) {
if (!QPixmapCache::find(key % HexString<uint>(mode), &pm)) {
if (pm.size() != actualSize)
pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
if (pe->mode != mode && mode != QIcon::Normal) {

View File

@ -340,7 +340,7 @@ void QImageIOHandler::setDevice(QIODevice *device)
/*!
Returns the device currently assigned to the QImageIOHandler. If
not device has been assigned, 0 is returned.
not device has been assigned, \nullptr is returned.
*/
QIODevice *QImageIOHandler::device() const
{

View File

@ -756,13 +756,13 @@ void QImageReader::setDevice(QIODevice *device)
d->device = device;
d->deleteDevice = false;
delete d->handler;
d->handler = 0;
d->handler = nullptr;
d->text.clear();
}
/*!
Returns the device currently assigned to QImageReader, or 0 if no
device has been assigned.
Returns the device currently assigned to QImageReader, or \nullptr
if no device has been assigned.
*/
QIODevice *QImageReader::device() const
{

View File

@ -407,8 +407,8 @@ void QImageWriter::setDevice(QIODevice *device)
}
/*!
Returns the device currently assigned to QImageWriter, or 0 if no
device has been assigned.
Returns the device currently assigned to QImageWriter, or \nullptr
if no device has been assigned.
*/
QIODevice *QImageWriter::device() const
{

View File

@ -659,7 +659,7 @@ void QMovie::setDevice(QIODevice *device)
/*!
Returns the device QMovie reads image data from. If no device has
currently been assigned, 0 is returned.
currently been assigned, \nullptr is returned.
\sa setDevice(), fileName()
*/

View File

@ -858,7 +858,7 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords)
break;
case QPicturePrivate::PdcSetWXform:
s >> i_8;
painter->setMatrixEnabled(i_8);
painter->setWorldMatrixEnabled(i_8);
break;
case QPicturePrivate::PdcSetWMatrix:
if (d->formatMajor >= 8) {
@ -1200,8 +1200,8 @@ QT_END_INCLUDE_NAMESPACE
\obsolete
Returns a string that specifies the picture format of the file \a
fileName, or 0 if the file cannot be read or if the format is not
recognized.
fileName, or \nullptr if the file cannot be read or if the format
is not recognized.
\sa load(), save()
*/
@ -1543,7 +1543,7 @@ const QPicture &QPictureIO::picture() const { return d->pi; }
int QPictureIO::status() const { return d->iostat; }
/*!
Returns the picture format string or 0 if no format has been
Returns the picture format string or \nullptr if no format has been
explicitly set.
*/
const char *QPictureIO::format() const { return d->frmt; }

View File

@ -469,10 +469,13 @@ QPixmapCacheEntry::~QPixmapCacheEntry()
pm_cache()->releaseKey(key);
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
\overload
Use bool find(const QString &, QPixmap *) instead.
Returns the pixmap associated with the \a key in the cache, or
null if there is no such pixmap.
@ -494,13 +497,14 @@ QPixmap *QPixmapCache::find(const QString &key)
/*!
\obsolete
Use bool find(const QString&, QPixmap*) instead.
Use bool find(const QString &, QPixmap *) instead.
*/
bool QPixmapCache::find(const QString &key, QPixmap& pixmap)
bool QPixmapCache::find(const QString &key, QPixmap &pixmap)
{
return find(key, &pixmap);
}
#endif
/*!
Looks for a cached pixmap associated with the given \a key in the cache.
@ -513,7 +517,7 @@ bool QPixmapCache::find(const QString &key, QPixmap& pixmap)
\snippet code/src_gui_image_qpixmapcache.cpp 1
*/
bool QPixmapCache::find(const QString &key, QPixmap* pixmap)
bool QPixmapCache::find(const QString &key, QPixmap *pixmap)
{
QPixmap *ptr = pm_cache()->object(key);
if (ptr && pixmap)
@ -530,7 +534,7 @@ bool QPixmapCache::find(const QString &key, QPixmap* pixmap)
\since 4.6
*/
bool QPixmapCache::find(const Key &key, QPixmap* pixmap)
bool QPixmapCache::find(const Key &key, QPixmap *pixmap)
{
//The key is not valid anymore, a flush happened before probably
if (!key.d || !key.d->isValid)

View File

@ -76,8 +76,12 @@ public:
static int cacheLimit();
static void setCacheLimit(int);
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use bool find(const QString &, QPixmap *) instead")
static QPixmap *find(const QString &key);
QT_DEPRECATED_X("Use bool find(const QString &, QPixmap *) instead")
static bool find(const QString &key, QPixmap &pixmap);
#endif
static bool find(const QString &key, QPixmap *pixmap);
static bool find(const Key &key, QPixmap *pixmap);
static bool insert(const QString &key, const QPixmap &pixmap);

View File

@ -564,8 +564,8 @@ void QCursor::setShape(Qt::CursorShape shape)
}
/*!
Returns the cursor bitmap, or 0 if it is one of the standard
cursors.
Returns the cursor bitmap, or \nullptr if it is one of the
standard cursors.
*/
const QBitmap *QCursor::bitmap() const
{
@ -575,8 +575,8 @@ const QBitmap *QCursor::bitmap() const
}
/*!
Returns the cursor bitmap mask, or 0 if it is one of the standard
cursors.
Returns the cursor bitmap mask, or \nullptr if it is one of the
standard cursors.
*/
const QBitmap *QCursor::mask() const

View File

@ -414,15 +414,14 @@ int QOpenGLContextPrivate::maxTextureSize()
/*!
Returns the last context which called makeCurrent in the current thread,
or 0, if no context is current.
or \nullptr, if no context is current.
*/
QOpenGLContext* QOpenGLContext::currentContext()
{
QGuiGLThreadContext *threadContext = qwindow_context_storage()->localData();
if (threadContext) {
if (threadContext)
return threadContext->context;
}
return 0;
return nullptr;
}
/*!

View File

@ -90,11 +90,11 @@ QWindow *QPlatformWindow::window() const
}
/*!
Returns the parent platform window (or 0 if orphan).
Returns the parent platform window (or \nullptr if orphan).
*/
QPlatformWindow *QPlatformWindow::parent() const
{
return window()->parent() ? window()->parent()->handle() : 0;
return window()->parent() ? window()->parent()->handle() : nullptr;
}
/*!

View File

@ -111,7 +111,7 @@ Q_GUI_EXPORT QPixmap qt_pixmapForBrush(int brushStyle, bool invert)
QString key = QLatin1String("$qt-brush$")
% HexString<uint>(brushStyle)
% QLatin1Char(invert ? '1' : '0');
if (!QPixmapCache::find(key, pm)) {
if (!QPixmapCache::find(key, &pm)) {
pm = QBitmap::fromData(QSize(8, 8), qt_patternForBrush(brushStyle, invert),
QImage::Format_MonoLSB);
QPixmapCache::insert(key, pm);

View File

@ -1054,7 +1054,7 @@ static void convertARGBToARGB32PM_avx2(uint *buffer, const uint *src, qsizetype
__m128i maskedAlphaMask = _mm256_castsi256_si128(alphaMask);
__m128i mask = maskFromCount((count - i) * sizeof(*src));
maskedAlphaMask = _mm_and_si128(mask, maskedAlphaMask);
__m128i srcVector = _mm_maskload_epi32(reinterpret_cast<const int *>(src), mask);
__m128i srcVector = _mm_maskload_epi32(reinterpret_cast<const int *>(src + i), mask);
if (!_mm_testz_si128(srcVector, maskedAlphaMask)) {
// keep the two _mm_test[zc]_siXXX next to each other
@ -1166,7 +1166,7 @@ static void convertARGBToRGBA64PM_avx2(QRgba64 *buffer, const uint *src, qsizety
__m128i maskedAlphaMask = _mm256_castsi256_si128(alphaMask);
__m128i mask = maskFromCount((count - i) * sizeof(*src));
maskedAlphaMask = _mm_and_si128(mask, maskedAlphaMask);
__m128i srcVector = _mm_maskload_epi32(reinterpret_cast<const int *>(src), mask);
__m128i srcVector = _mm_maskload_epi32(reinterpret_cast<const int *>(src + i), mask);
__m256i src;
if (!_mm_testz_si128(srcVector, maskedAlphaMask)) {

View File

@ -1521,7 +1521,7 @@ QPainter::~QPainter()
/*!
Returns the paint device on which this painter is currently
painting, or 0 if the painter is not active.
painting, or \nullptr if the painter is not active.
\sa isActive()
*/
@ -1547,6 +1547,7 @@ bool QPainter::isActive() const
return d->engine;
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
Initializes the painters pen, background and font to the same as
the given \a device.
@ -1574,7 +1575,7 @@ void QPainter::initFrom(const QPaintDevice *device)
d->engine->setDirty(QPaintEngine::DirtyFont);
}
}
#endif
/*!
Saves the current painter state (pushes the state onto a stack). A
@ -2885,6 +2886,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op)
d->updateState(d->state);
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\since 4.2
\obsolete
@ -3048,7 +3050,7 @@ void QPainter::resetMatrix()
{
resetTransform();
}
#endif
/*!
\since 4.2
@ -3099,6 +3101,7 @@ bool QPainter::worldMatrixEnabled() const
return d->state->WxF;
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
@ -3124,6 +3127,7 @@ bool QPainter::matrixEnabled() const
{
return worldMatrixEnabled();
}
#endif
/*!
Scales the coordinate system by (\a{sx}, \a{sy}).
@ -4182,6 +4186,7 @@ void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius,
Draws the given rectangle \a x, \a y, \a w, \a h with rounded corners.
*/
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
@ -4209,6 +4214,10 @@ void QPainter::drawRoundRect(const QRectF &r, int xRnd, int yRnd)
Draws the rectangle \a r with rounded corners.
*/
void QPainter::drawRoundRect(const QRect &rect, int xRnd, int yRnd)
{
drawRoundRect(QRectF(rect), xRnd, yRnd);
}
/*!
\obsolete
@ -4219,6 +4228,11 @@ void QPainter::drawRoundRect(const QRectF &r, int xRnd, int yRnd)
Draws the rectangle \a x, \a y, \a w, \a h with rounded corners.
*/
void QPainter::drawRoundRect(int x, int y, int w, int h, int xRnd, int yRnd)
{
drawRoundRect(QRectF(x, y, w, h), xRnd, yRnd);
}
#endif
/*!
\fn void QPainter::drawEllipse(const QRectF &rectangle)
@ -6210,7 +6224,7 @@ static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
% HexString<qreal>(pen.widthF());
QPixmap pixmap;
if (QPixmapCache::find(key, pixmap))
if (QPixmapCache::find(key, &pixmap))
return pixmap;
const qreal halfPeriod = qMax(qreal(2), qreal(radiusBase * 1.61803399)); // the golden ratio
@ -7378,6 +7392,7 @@ void QPainter::setViewTransformEnabled(bool enable)
d->updateMatrix();
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\threadsafe
@ -7458,6 +7473,7 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)
Q_UNUSED(offset)
return 0;
}
#endif
void qt_format_text(const QFont &fnt, const QRectF &_r,
int tf, const QString& str, QRectF *brect,
@ -8067,6 +8083,7 @@ QFont QPaintEngineState::font() const
return static_cast<const QPainterState *>(this)->font;
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\since 4.2
\obsolete
@ -8089,6 +8106,7 @@ QMatrix QPaintEngineState::matrix() const
return st->matrix.toAffine();
}
#endif
/*!
\since 4.3

View File

@ -132,7 +132,10 @@ public:
bool end();
bool isActive() const;
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use begin(QPaintDevice*) instead")
void initFrom(const QPaintDevice *device);
#endif
enum CompositionMode {
CompositionMode_SourceOver,
@ -232,28 +235,40 @@ public:
void restore();
// XForm functions
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use setTransform() instead")
void setMatrix(const QMatrix &matrix, bool combine = false);
QT_DEPRECATED_X("Use transform() instead")
const QMatrix &matrix() const;
QT_DEPRECATED_X("Use deviceTransform() instead")
const QMatrix &deviceMatrix() const;
QT_DEPRECATED_X("Use resetTransform() instead")
void resetMatrix();
#endif
void setTransform(const QTransform &transform, bool combine = false);
const QTransform &transform() const;
const QTransform &deviceTransform() const;
void resetTransform();
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use setWorldTransform() instead")
void setWorldMatrix(const QMatrix &matrix, bool combine = false);
QT_DEPRECATED_X("Use worldTransform() instead")
const QMatrix &worldMatrix() const;
QT_DEPRECATED_X("Use combinedTransform() instead")
QMatrix combinedMatrix() const;
QT_DEPRECATED_X("Use setWorldMatrixEnabled() instead")
void setMatrixEnabled(bool enabled);
QT_DEPRECATED_X("Use worldMatrixEnabled() instead")
bool matrixEnabled() const;
#endif
void setWorldTransform(const QTransform &matrix, bool combine = false);
const QTransform &worldTransform() const;
QMatrix combinedMatrix() const;
QTransform combinedTransform() const;
void setMatrixEnabled(bool enabled);
bool matrixEnabled() const;
void setWorldMatrixEnabled(bool enabled);
bool worldMatrixEnabled() const;
@ -355,9 +370,14 @@ public:
inline void drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius,
Qt::SizeMode mode = Qt::AbsoluteSize);
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use drawRoundedRect(..., Qt::RelativeSize) instead")
void drawRoundRect(const QRectF &r, int xround = 25, int yround = 25);
inline void drawRoundRect(int x, int y, int w, int h, int = 25, int = 25);
inline void drawRoundRect(const QRect &r, int xround = 25, int yround = 25);
QT_DEPRECATED_X("Use drawRoundedRect(..., Qt::RelativeSize) instead")
void drawRoundRect(int x, int y, int w, int h, int = 25, int = 25);
QT_DEPRECATED_X("Use drawRoundedRect(..., Qt::RelativeSize) instead")
void drawRoundRect(const QRect &r, int xround = 25, int yround = 25);
#endif
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset = QPointF());
inline void drawTiledPixmap(int x, int y, int w, int h, const QPixmap &, int sx=0, int sy=0);
@ -464,10 +484,15 @@ public:
QPaintEngine *paintEngine() const;
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use QWidget::render() instead")
static void setRedirected(const QPaintDevice *device, QPaintDevice *replacement,
const QPoint& offset = QPoint());
QT_DEPRECATED_X("Use QWidget::render() instead")
static QPaintDevice *redirected(const QPaintDevice *device, QPoint *offset = nullptr);
QT_DEPRECATED_X("Use QWidget::render() instead")
static void restoreRedirected(const QPaintDevice *device);
#endif
void beginNativePainting();
void endNativePainting();
@ -629,16 +654,6 @@ inline void QPainter::drawPoints(const QPolygon &points)
drawPoints(points.constData(), points.size());
}
inline void QPainter::drawRoundRect(int x, int y, int w, int h, int xRnd, int yRnd)
{
drawRoundRect(QRectF(x, y, w, h), xRnd, yRnd);
}
inline void QPainter::drawRoundRect(const QRect &rect, int xRnd, int yRnd)
{
drawRoundRect(QRectF(rect), xRnd, yRnd);
}
inline void QPainter::drawRoundedRect(int x, int y, int w, int h, qreal xRadius, qreal yRadius,
Qt::SizeMode mode)
{

View File

@ -3242,6 +3242,7 @@ void QPainterPath::addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadi
Adds the given rectangle \a x, \a y, \a w, \a h with rounded corners to the path.
*/
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
@ -3308,6 +3309,17 @@ void QPainterPath::addRoundRect(const QRectF &r, int xRnd, int yRnd)
\sa addRoundedRect()
*/
void QPainterPath::addRoundRect(const QRectF &rect,
int roundness)
{
int xRnd = roundness;
int yRnd = roundness;
if (rect.width() > rect.height())
xRnd = int(roundness * rect.height()/rect.width());
else
yRnd = int(roundness * rect.width()/rect.height());
addRoundRect(rect, xRnd, yRnd);
}
/*!
\obsolete
@ -3324,6 +3336,11 @@ void QPainterPath::addRoundRect(const QRectF &r, int xRnd, int yRnd)
\sa addRoundedRect()
*/
void QPainterPath::addRoundRect(qreal x, qreal y, qreal w, qreal h,
int xRnd, int yRnd)
{
addRoundRect(QRectF(x, y, w, h), xRnd, yRnd);
}
/*!
\obsolete
@ -3343,6 +3360,12 @@ void QPainterPath::addRoundRect(const QRectF &r, int xRnd, int yRnd)
\sa addRoundedRect()
*/
void QPainterPath::addRoundRect(qreal x, qreal y, qreal w, qreal h,
int roundness)
{
addRoundRect(QRectF(x, y, w, h), roundness);
}
#endif
/*!
\since 4.3
@ -3397,6 +3420,7 @@ QPainterPath QPainterPath::subtracted(const QPainterPath &p) const
return clipper.clip(QPathClipper::BoolSub);
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\since 4.3
\obsolete
@ -3409,6 +3433,7 @@ QPainterPath QPainterPath::subtractedInverted(const QPainterPath &p) const
{
return p.subtracted(*this);
}
#endif
/*!
\since 4.4

View File

@ -143,12 +143,18 @@ public:
qreal xRadius, qreal yRadius,
Qt::SizeMode mode = Qt::AbsoluteSize);
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead")
void addRoundRect(const QRectF &rect, int xRnd, int yRnd);
inline void addRoundRect(qreal x, qreal y, qreal w, qreal h,
int xRnd, int yRnd);
inline void addRoundRect(const QRectF &rect, int roundness);
inline void addRoundRect(qreal x, qreal y, qreal w, qreal h,
int roundness);
QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead")
void addRoundRect(qreal x, qreal y, qreal w, qreal h,
int xRnd, int yRnd);
QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead")
void addRoundRect(const QRectF &rect, int roundness);
QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead")
void addRoundRect(qreal x, qreal y, qreal w, qreal h,
int roundness);
#endif
void connectPath(const QPainterPath &path);
@ -193,7 +199,10 @@ public:
Q_REQUIRED_RESULT QPainterPath united(const QPainterPath &r) const;
Q_REQUIRED_RESULT QPainterPath intersected(const QPainterPath &r) const;
Q_REQUIRED_RESULT QPainterPath subtracted(const QPainterPath &r) const;
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use r.subtracted() instead")
Q_REQUIRED_RESULT QPainterPath subtractedInverted(const QPainterPath &r) const;
#endif
Q_REQUIRED_RESULT QPainterPath simplified() const;
@ -338,30 +347,6 @@ inline void QPainterPath::addRoundedRect(qreal x, qreal y, qreal w, qreal h,
addRoundedRect(QRectF(x, y, w, h), xRadius, yRadius, mode);
}
inline void QPainterPath::addRoundRect(qreal x, qreal y, qreal w, qreal h,
int xRnd, int yRnd)
{
addRoundRect(QRectF(x, y, w, h), xRnd, yRnd);
}
inline void QPainterPath::addRoundRect(const QRectF &rect,
int roundness)
{
int xRnd = roundness;
int yRnd = roundness;
if (rect.width() > rect.height())
xRnd = int(roundness * rect.height()/rect.width());
else
yRnd = int(roundness * rect.width()/rect.height());
addRoundRect(rect, xRnd, yRnd);
}
inline void QPainterPath::addRoundRect(qreal x, qreal y, qreal w, qreal h,
int roundness)
{
addRoundRect(QRectF(x, y, w, h), roundness);
}
inline void QPainterPath::addText(qreal x, qreal y, const QFont &f, const QString &text)
{
addText(QPointF(x, y), f, text);

View File

@ -206,8 +206,8 @@ void QTextDocumentWriter::setDevice (QIODevice *device)
}
/*!
Returns the device currently assigned, or 0 if no device has been
assigned.
Returns the device currently assigned, or \nullptr if no device
has been assigned.
*/
QIODevice *QTextDocumentWriter::device () const
{

View File

@ -704,8 +704,8 @@ QTextFrame::iterator &QTextFrame::iterator::operator=(const iterator &other) Q_D
#endif
/*!
Returns the current frame pointed to by the iterator, or 0 if the
iterator currently points to a block.
Returns the current frame pointed to by the iterator, or \nullptr
if the iterator currently points to a block.
\sa currentBlock()
*/
@ -1291,12 +1291,12 @@ QVector<QTextLayout::FormatRange> QTextBlock::textFormats() const
}
/*!
Returns the text document this text block belongs to, or 0 if the
text block does not belong to any document.
Returns the text document this text block belongs to, or \nullptr
if the text block does not belong to any document.
*/
const QTextDocument *QTextBlock::document() const
{
return p ? p->document() : 0;
return p ? p->document() : nullptr;
}
/*!
@ -1306,7 +1306,7 @@ const QTextDocument *QTextBlock::document() const
QTextList *QTextBlock::textList() const
{
if (!isValid())
return 0;
return nullptr;
const QTextBlockFormat fmt = blockFormat();
QTextObject *obj = p->document()->objectForFormat(fmt);

View File

@ -326,7 +326,7 @@ QString QSslError::errorString() const
errStr = QSslSocket::tr("The client is not authorized to request OCSP status from this server");
break;
case OcspResponseCannotBeTrusted:
errStr = QSslSocket::tr("OCSP reponder's identity cannot be verified");
errStr = QSslSocket::tr("OCSP responder's identity cannot be verified");
break;
case OcspResponseCertIdUnknown:
errStr = QSslSocket::tr("The identity of a certificate in an OCSP response cannot be established");

View File

@ -617,10 +617,10 @@ bool QSslSocketBackendPrivate::acquireCredentialsHandle()
&findParam,
nullptr);
if (!chainContext) {
setErrorAndEmit(QAbstractSocket::SocketError::SslInvalidUserDataError,
QSslSocket::tr("The certificate provided can not be used for a %1.")
.arg(isClient ? QSslSocket::tr("client")
: QSslSocket::tr("server")));
const QString message = isClient
? QSslSocket::tr("The certificate provided can not be used for a client.")
: QSslSocket::tr("The certificate provided can not be used for a server.");
setErrorAndEmit(QAbstractSocket::SocketError::SslInvalidUserDataError, message);
return false;
}
Q_ASSERT(chainContext->cChain == 1);

View File

@ -76,7 +76,7 @@ QPixmap QAbstractFileIconEngine::pixmap(const QSize &size, QIcon::Mode mode,
key += QLatin1Char('_') + QString::number(size.width());
QPixmap result;
if (!QPixmapCache::find(key, result)) {
if (!QPixmapCache::find(key, &result)) {
result = filePixmap(size, mode, state);
if (!result.isNull())
QPixmapCache::insert(key, result);

View File

@ -458,7 +458,7 @@ static QPixmap qt_patternForAlpha(uchar alpha, int screen)
% HexString<uchar>(alpha)
% HexString<int>(screen);
if (!QPixmapCache::find(key, pm)) {
if (!QPixmapCache::find(key, &pm)) {
// #### why not use a mono image here????
QImage pattern(DITHER_SIZE, DITHER_SIZE, QImage::Format_ARGB32);
pattern.fill(0xffffffff);

View File

@ -422,7 +422,7 @@ QDialog::~QDialog()
/*!
\internal
This function is called by the push button \a pushButton when it
becomes the default button. If \a pushButton is 0, the dialogs
becomes the default button. If \a pushButton is \nullptr, the dialogs
default default button becomes the default button. This is what a
push button calls when it loses focus.
*/
@ -1014,7 +1014,7 @@ void QDialog::setExtension(QWidget* extension)
/*!
\obsolete
Returns the dialog's extension or 0 if no extension has been
Returns the dialog's extension or \nullptr if no extension has been
defined.
Instead of using this functionality, we recommend that you simply call

View File

@ -3695,7 +3695,7 @@ void QFileDialogPrivate::_q_goToDirectory(const QString &path)
}
QDir dir(path2);
if (!dir.exists())
dir = getEnvironmentVariable(path2);
dir.setPath(getEnvironmentVariable(path2));
if (dir.exists() || path2.isEmpty() || path2 == model->myComputer().toString()) {
_q_enterDirectory(index);

View File

@ -834,7 +834,7 @@ QMessageBox::QMessageBox(QWidget *parent)
The message box is an \l{Qt::ApplicationModal} {application modal}
dialog box.
On \macos, if \a parent is not 0 and you want your message box
On \macos, if \a parent is not \nullptr and you want your message box
to appear as a Qt::Sheet of that parent, set the message box's
\l{setWindowModality()} {window modality} to Qt::WindowModal
(default). Otherwise, the message box will be a standard dialog.
@ -983,7 +983,7 @@ QMessageBox::StandardButton QMessageBox::standardButton(QAbstractButton *button)
\since 4.2
Returns a pointer corresponding to the standard button \a which,
or 0 if the standard button doesn't exist in this message box.
or \nullptr if the standard button doesn't exist in this message box.
\sa standardButtons, standardButton()
*/
@ -1106,7 +1106,7 @@ void QMessageBoxPrivate::detectEscapeButton()
\since 4.2
Returns the button that was clicked by the user,
or 0 if the user hit the \uicontrol Esc key and
or \nullptr if the user hit the \uicontrol Esc key and
no \l{setEscapeButton()}{escape button} was set.
If exec() hasn't been called yet, returns nullptr.
@ -1173,7 +1173,7 @@ void QMessageBox::setDefaultButton(QMessageBox::StandardButton button)
/*! \since 5.2
Sets the checkbox \a cb on the message dialog. The message box takes ownership of the checkbox.
The argument \a cb can be 0 to remove an existing checkbox from the message box.
The argument \a cb can be \nullptr to remove an existing checkbox from the message box.
\sa checkBox()
*/
@ -1205,7 +1205,7 @@ void QMessageBox::setCheckBox(QCheckBox *cb)
/*! \since 5.2
Returns the checkbox shown on the dialog. This is 0 if no checkbox is set.
Returns the checkbox shown on the dialog. This is \nullptr if no checkbox is set.
\sa setCheckBox()
*/
@ -1570,7 +1570,7 @@ QList<QAbstractButton *> QMessageBox::buttons() const
\since 4.5
Returns the button role for the specified \a button. This function returns
\l InvalidRole if \a button is 0 or has not been added to the message box.
\l InvalidRole if \a button is \nullptr or has not been added to the message box.
\sa buttons(), addButton()
*/
@ -1835,7 +1835,7 @@ void QMessageBox::about(QWidget *parent, const QString &title, const QString &te
/*!
Displays a simple message box about Qt, with the given \a title
and centered over \a parent (if \a parent is not 0). The message
and centered over \a parent (if \a parent is not \nullptr). The message
includes the version number of Qt being used by the application.
This is useful for inclusion in the \uicontrol Help menu of an application,

View File

@ -2374,8 +2374,8 @@ void QWizard::removePage(int id)
/*!
\fn QWizardPage *QWizard::page(int id) const
Returns the page with the given \a id, or 0 if there is no such
page.
Returns the page with the given \a id, or \nullptr if there is no
such page.
\sa addPage(), setPage()
*/
@ -2462,8 +2462,8 @@ int QWizard::startId() const
}
/*!
Returns a pointer to the current page, or 0 if there is no current
page (e.g., before the wizard is shown).
Returns a pointer to the current page, or \nullptr if there is no
current page (e.g., before the wizard is shown).
This is equivalent to calling page(currentId()).
@ -2954,7 +2954,7 @@ void QWizard::setDefaultProperty(const char *className, const char *property,
Passing 0 shows no side widget.
When the \a widget is not 0 the wizard reparents it.
When the \a widget is not \nullptr the wizard reparents it.
Any previous side widget is hidden.
@ -2963,7 +2963,7 @@ void QWizard::setDefaultProperty(const char *className, const char *property,
All widgets set here will be deleted by the wizard when it is
destroyed unless you separately reparent the widget after setting
some other side widget (or 0).
some other side widget (or \nullptr).
By default, no side widget is present.
*/
@ -2981,7 +2981,7 @@ void QWizard::setSideWidget(QWidget *widget)
/*!
\since 4.7
Returns the widget on the left side of the wizard or 0.
Returns the widget on the left side of the wizard or \nullptr.
By default, no side widget is present.
*/
@ -3969,7 +3969,7 @@ void QWizardPage::registerField(const QString &name, QWidget *widget, const char
}
/*!
Returns the wizard associated with this page, or 0 if this page
Returns the wizard associated with this page, or \nullptr if this page
hasn't been inserted into a QWizard yet.
\sa QWizard::addPage(), QWizard::setPage()

View File

@ -59,7 +59,7 @@ mapper->toFirst();
//! [1]
QDataWidgetMapper *mapper = new QDataWidgetMapper();
QDataWidgetMapper *mapper = new QDataWidgetMapper;
mapper->setModel(myModel);
mapper->addMapping(nameLineEdit, 0);
mapper->addMapping(ageSpinBox, 1);
@ -67,7 +67,7 @@ mapper->addMapping(ageSpinBox, 1);
//! [2]
QDataWidgetMapper *mapper = new QDataWidgetMapper();
connect(myTableView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
mapper, SLOT(setCurrentModelIndex(QModelIndex)));
QDataWidgetMapper *mapper = new QDataWidgetMapper;
connect(myTableView->selectionModel(), &QItemSelectionModel::currentRowChanged,
mapper, &QDataWidgetMapper::setCurrentModelIndex);
//! [2]

View File

@ -100,7 +100,8 @@ QSize MyWidget::sizeHint() const
//! [4]
void showAllHiddenTopLevelWidgets()
{
foreach (QWidget *widget, QApplication::topLevelWidgets()) {
const QWidgetList topLevelWidgets = QApplication::topLevelWidgets();
for (QWidget *widget : topLevelWidgets) {
if (widget->isHidden())
widget->show();
}
@ -111,7 +112,8 @@ void showAllHiddenTopLevelWidgets()
//! [5]
void updateAllWidgets()
{
foreach (QWidget *widget, QApplication::allWidgets())
const QWidgetList allWidgets = QApplication::allWidgets();
for (QWidget *widget : allWidgets)
widget->update();
}
//! [5]
@ -171,13 +173,15 @@ appname -session id
//! [10]
foreach (const QString &command, mySession.restartCommand())
const QStringList commands = mySession.restartCommand();
for (const QString &command : commands)
do_something(command);
//! [10]
//! [11]
foreach (const QString &command, mySession.discardCommand())
const QStringList commands = mySession.discardCommand();
for (const QString &command : commands)
do_something(command);
//! [11]

View File

@ -81,7 +81,7 @@ exec(e->globalPos());
//! [6]
QMenu menu;
QAction *at = actions[0]; // Assumes actions is not empty
foreach (QAction *a, actions)
for (QAction *a : qAsConst(actions))
menu.addAction(a);
menu.exec(pos, at);
//! [6]

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
typedef QDialog WordCountDialog;
typedef QDialog FindDialog;
@ -76,7 +76,8 @@ void EditorWindow::find()
{
if (!findDialog) {
findDialog = new FindDialog(this);
connect(findDialog, SIGNAL(findNext()), this, SLOT(findNext()));
connect(findDialog, &FindDialog::findNext,
this, &EditorWindow::findNext);
}
findDialog->show();
@ -249,9 +250,9 @@ Operation::Operation(QObject *parent)
: QObject(parent), steps(0)
{
pd = new QProgressDialog("Operation in progress.", "Cancel", 0, 100);
connect(pd, SIGNAL(canceled()), this, SLOT(cancel()));
connect(pd, &QProgressDialog::canceled, this, &Operation::cancel);
t = new QTimer(this);
connect(t, SIGNAL(timeout()), this, SLOT(perform()));
connect(t, &QTimer::timeout, this, &Operation::perform);
t->start(0);
}
//! [4] //! [5]

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
@ -63,8 +63,8 @@ MainWindow::MainWindow(QWidget *parent)
textBrowser = new QTextBrowser(this);
connect(headingList, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(updateText(QListWidgetItem*)));
connect(headingList, &QListWidget::itemClicked,
this, &MainWindow::updateText);
updateText(headingList->item(0));
headingList->setCurrentRow(0);
@ -119,7 +119,7 @@ void MainWindow::setupMenus()
QAction *exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcut(tr("Ctrl+Q"));
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
connect(exitAct, &QAction::triggered, qApp, &QApplication::closeAllWindows);
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(exitAct);

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
void mainWindowExample()
{
@ -95,7 +95,7 @@ int main(int argv, char **args)
QAction *act = new QAction(qApp);
act->setShortcut(Qt::ALT + Qt::Key_S);
act->setShortcutContext( Qt::ApplicationShortcut );
QObject::connect(act, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
QObject::connect(act, &QAction::triggered, qApp, &QApplication::aboutQt);
QWidget widget5;
widget5.show();

View File

@ -73,7 +73,8 @@ listView->setDropIndicatorShown(true);
this->listView = listView;
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(quitAction, &QAction::triggered,
this, &QWidget::close);
setupListItems();

View File

@ -54,7 +54,7 @@
A simple model that uses a QStringList as its data source.
*/
#include <QtGui>
#include <QtWidgets>
#include "model.h"
@ -121,7 +121,7 @@ bool DragDropListModel::dropMimeData(const QMimeData *data,
//! [6]
insertRows(beginRow, rows, QModelIndex());
foreach (const QString &text, newItems) {
for (const QString &text : qAsConst(newItems)) {
QModelIndex idx = index(beginRow, 0, QModelIndex());
setData(idx, text);
beginRow++;
@ -146,12 +146,12 @@ Qt::ItemFlags DragDropListModel::flags(const QModelIndex &index) const
//! [8]
QMimeData *DragDropListModel::mimeData(const QModelIndexList &indexes) const
{
QMimeData *mimeData = new QMimeData();
QMimeData *mimeData = new QMimeData;
QByteArray encodedData;
QDataStream stream(&encodedData, QIODevice::WriteOnly);
foreach (const QModelIndex &index, indexes) {
for (const QModelIndex &index : indexes) {
if (index.isValid()) {
QString text = data(index, Qt::DisplayRole).toString();
stream << text;

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
@ -74,7 +74,7 @@ listWidget->setDragDropMode(QAbstractItemView::InternalMove);
this->listWidget = listWidget;
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(quitAction, &QAction::triggered, this, &QWidget::close);
setupListItems();

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
@ -77,14 +77,13 @@ MainWindow::MainWindow()
listWidget = new QListWidget(this);
listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
connect(listWidget,
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(updateMenus(QListWidgetItem*)));
connect(quitAction, &QAction::triggered, this, &QWidget::close);
connect(ascendingAction, &QAction::triggered, this, &MainWindow::sortAscending);
connect(descendingAction, &QAction::triggered, this, &MainWindow::sortDescending);
connect(insertAction, &QAction::triggered, this, &MainWindow::insertItem);
connect(removeAction, &QAction::triggered, this, &MainWindow::removeItem);
connect(listWidget, &QListWidget::currentItemChanged,
this, &MainWindow::updateMenus);
setupListItems();
updateMenus(listWidget->currentItem());

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
int main(int argc, char *argv[])
{
@ -74,9 +74,8 @@ int main(int argc, char *argv[])
filteredView->setWindowTitle("Filtered view onto a string list model");
QLineEdit *patternEditor = new QLineEdit;
QObject::
connect(patternEditor, SIGNAL(textChanged(QString)),
filterModel, SLOT(setFilterRegExp(QString)));
QObject::connect(patternEditor, &QLineEdit::textChanged,
filterModel, &QSortFilterProxyModel::setFilterWildcard);
QVBoxLayout *layout = new QVBoxLayout(window);
layout->addWidget(filteredView);

View File

@ -48,13 +48,12 @@
**
****************************************************************************/
#include <QtGui>
#include <QApplication>
#include <QtWidgets>
class Widget : public QWidget
{
public:
Widget(QWidget *parent = 0);
Widget(QWidget *parent = nullptr);
};
Widget::Widget(QWidget *parent)
@ -75,8 +74,8 @@ Widget::Widget(QWidget *parent)
pageComboBox->addItem(tr("Page 1"));
pageComboBox->addItem(tr("Page 2"));
pageComboBox->addItem(tr("Page 3"));
connect(pageComboBox, SIGNAL(activated(int)),
stackedLayout, SLOT(setCurrentIndex(int)));
connect(pageComboBox, QOverload<int>::of(&QComboBox::activated),
stackedLayout, &QStackedLayout::setCurrentIndex);
//! [1]
//! [2]

View File

@ -48,8 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QApplication>
#include <QtWidgets>
class Widget : public QWidget
{
@ -75,8 +74,8 @@ Widget::Widget(QWidget *parent)
pageComboBox->addItem(tr("Page 1"));
pageComboBox->addItem(tr("Page 2"));
pageComboBox->addItem(tr("Page 3"));
connect(pageComboBox, SIGNAL(activated(int)),
stackedWidget, SLOT(setCurrentIndex(int)));
connect(pageComboBox, QOverload<int>::of(&QComboBox::activated),
stackedWidget, &QStackedWidget::setCurrentIndex);
//! [1] //! [2]
QVBoxLayout *layout = new QVBoxLayout;

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
@ -72,9 +72,9 @@ MainWindow::MainWindow()
//! [0]
tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(tableWidthAction, SIGNAL(triggered()), this, SLOT(changeWidth()));
connect(tableHeightAction, SIGNAL(triggered()), this, SLOT(changeHeight()));
connect(quitAction, &QAction::triggered, this, &QWidget::close);
connect(tableWidthAction, &QAction::triggered, this, &MainWindow::changeWidth);
connect(tableHeightAction, &QAction::triggered, this, &MainWindow::changeHeight);
setupTableItems();

View File

@ -48,8 +48,8 @@
**
****************************************************************************/
#include <QtGui>
#include "math.h"
#include <QtWidgets>
#include <math.h>
#include "mainwindow.h"
@ -89,9 +89,9 @@ MainWindow::MainWindow()
tableWidget->setHorizontalHeaderItem(1, squaresHeaderItem);
tableWidget->setHorizontalHeaderItem(2, cubesHeaderItem);
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(sumItemsAction, SIGNAL(triggered()), this, SLOT(sumItems()));
connect(averageItemsAction, SIGNAL(triggered()), this, SLOT(averageItems()));
connect(quitAction, &QAction::triggered, this, &QWidget::close);
connect(sumItemsAction, &QAction::triggered, this, &MainWindow::sumItems);
connect(averageItemsAction, &QAction::triggered, this, &MainWindow::averageItems);
setupTableItems();
@ -119,12 +119,11 @@ void MainWindow::setupTableItems()
void MainWindow::averageItems()
{
QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
QTableWidgetItem *item;
const QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
int number = 0;
double total = 0;
foreach (item, selected) {
for (QTableWidgetItem *item : selected) {
bool ok;
double value = item->text().toDouble(&ok);
@ -140,12 +139,11 @@ void MainWindow::averageItems()
void MainWindow::sumItems()
{
//! [4]
QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
QTableWidgetItem *item;
const QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
int number = 0;
double total = 0;
foreach (item, selected) {
for (QTableWidgetItem *item : selected) {
bool ok;
double value = item->text().toDouble(&ok);

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
@ -90,16 +90,15 @@ MainWindow::MainWindow()
treeWidget->setHeaderLabels(headers);
//! [2]
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
connect(autoSortAction, SIGNAL(triggered()), this, SLOT(updateSortItems()));
connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
connect(findItemsAction, SIGNAL(triggered()), this, SLOT(findItems()));
connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
connect(treeWidget,
SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
this, SLOT(updateMenus(QTreeWidgetItem*)));
connect(quitAction, &QAction::triggered, this, &QWidget::close);
connect(ascendingAction, &QAction::triggered, this, &MainWindow::sortAscending);
connect(autoSortAction, &QAction::triggered, this, &MainWindow::updateSortItems);
connect(descendingAction, &QAction::triggered, this, &MainWindow::sortDescending);
connect(findItemsAction, &QAction::triggered, this, &MainWindow::findItems);
connect(insertAction, &QAction::triggered, this, &MainWindow::insertItem);
connect(removeAction, &QAction::triggered, this, &MainWindow::removeItem);
connect(treeWidget, &QTreeWidget::currentItemChanged,
this, &MainWindow::updateMenus);
setupTreeItems();
updateMenus(treeWidget->currentItem());
@ -150,17 +149,15 @@ void MainWindow::findItems()
if (itemText.isEmpty())
return;
//! [6]
QTreeWidgetItem *item;
//! [6]
foreach (item, treeWidget->selectedItems())
const QList<QTreeWidgetItem *> items = treeWidget->selectedItems();
for (QTreeWidgetItem *item : items)
item->setSelected(false);
//! [7]
QList<QTreeWidgetItem *> found = treeWidget->findItems(
const QList<QTreeWidgetItem *> found = treeWidget->findItems(
itemText, Qt::MatchWildcard);
foreach (item, found) {
for (QTreeWidgetItem *item : found) {
item->setSelected(true);
// Show the item->text(0) for each item.
}

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "mainwindow.h"
@ -85,16 +85,15 @@ MainWindow::MainWindow()
headers << tr("Subject") << tr("Default");
treeWidget->setHeaderLabels(headers);
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
connect(autoSortAction, SIGNAL(triggered()), this, SLOT(updateSortItems()));
connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
connect(findItemsAction, SIGNAL(triggered()), this, SLOT(findItems()));
connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
connect(treeWidget,
SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
this, SLOT(updateMenus(QTreeWidgetItem*)));
connect(quitAction, &QAction::triggered, this, &QWidget::close);
connect(ascendingAction, &QAction::triggered, this, &MainWindow::sortAscending);
connect(autoSortAction, &QAction::triggered, this, &MainWindow::updateSortItems);
connect(descendingAction, &QAction::triggered, this, &MainWindow::sortDescending);
connect(findItemsAction, &QAction::triggered, this, &MainWindow::findItems);
connect(insertAction, &QAction::triggered, this, &MainWindow::insertItem);
connect(removeAction, &QAction::triggered, this, &MainWindow::removeItem);
connect(treeWidget, &QTreeWidget::currentItemChanged,
this, &MainWindow::updateMenus);
setupTreeItems();
updateMenus(treeWidget->currentItem());

View File

@ -81,9 +81,9 @@ MainWindow::MainWindow(QWidget *parent)
QAction *selectAllAction = actionMenu->addAction(tr("&Select All"));
menuBar()->addMenu(actionMenu);
connect(fillAction, SIGNAL(triggered()), this, SLOT(fillSelection()));
connect(clearAction, SIGNAL(triggered()), this, SLOT(clearSelection()));
connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll()));
connect(fillAction, &QAction::triggered, this, &MainWindow::fillSelection);
connect(clearAction, &QAction::triggered, this, &MainWindow::clearSelection);
connect(selectAllAction, &QAction::triggered, this, &MainWindow::selectAll);
selectionModel = table->selectionModel();
@ -94,10 +94,9 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::fillSelection()
{
//! [0]
QModelIndexList indexes = selectionModel->selectedIndexes();
QModelIndex index;
const QModelIndexList indexes = selectionModel->selectedIndexes();
foreach(index, indexes) {
for (const QModelIndex &index : indexes) {
QString text = QString("(%1,%2)").arg(index.row()).arg(index.column());
model->setData(index, text);
}
@ -106,11 +105,10 @@ void MainWindow::fillSelection()
void MainWindow::clearSelection()
{
QModelIndexList indexes = selectionModel->selectedIndexes();
QModelIndex index;
const QModelIndexList indexes = selectionModel->selectedIndexes();
foreach(index, indexes)
model->setData(index, "");
for (const QModelIndex &index : indexes)
model->setData(index, QString());
}
void MainWindow::selectAll()

View File

@ -74,12 +74,10 @@ MainWindow::MainWindow(QWidget *parent)
table->setModel(model);
selectionModel = table->selectionModel();
connect(selectionModel,
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(updateSelection(QItemSelection,QItemSelection)));
connect(selectionModel,
SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(changeCurrent(QModelIndex,QModelIndex)));
connect(selectionModel, &QItemSelectionModel::selectionChanged,
this, &MainWindow::updateSelection);
connect(selectionModel, &QItemSelectionModel::currentChanged,
this, &MainWindow::changeCurrent);
statusBar();
setCentralWidget(table);
@ -89,10 +87,9 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::updateSelection(const QItemSelection &selected,
const QItemSelection &deselected)
{
QModelIndex index;
QModelIndexList items = selected.indexes();
foreach (index, items) {
for (const QModelIndex &index : qAsConst(items)) {
QString text = QString("(%1,%2)").arg(index.row()).arg(index.column());
model->setData(index, text);
//! [0] //! [1]
@ -102,8 +99,8 @@ void MainWindow::updateSelection(const QItemSelection &selected,
//! [2]
items = deselected.indexes();
foreach (index, items)
model->setData(index, "");
for (const QModelIndex &index : qAsConst(items)) {
model->setData(index, QString());
}
//! [2]

View File

@ -1003,8 +1003,8 @@
\snippet reading-selections/window.cpp 0
The above code uses Qt's convenient \l{Container Classes}{foreach
keyword} to iterate over, and modify, the items corresponding to the
The above code uses a range-based for-loop to iterate over,
and modify, the items corresponding to the
indexes returned by the selection model.
The selection model emits signals to indicate changes in the
@ -1611,7 +1611,6 @@
We can obtain a list of matching items with the \c findItems()
function:
\snippet qtreewidget-using/mainwindow.cpp 6
\snippet qtreewidget-using/mainwindow.cpp 7
The above code causes items in a tree widget to be selected if they

View File

@ -552,20 +552,19 @@ int QGraphicsGridLayout::count() const
}
/*!
Returns the layout item at \a index, or 0 if there is no layout item at
this index.
Returns the layout item at \a index, or \nullptr if there is no
layout item at this index.
*/
QGraphicsLayoutItem *QGraphicsGridLayout::itemAt(int index) const
{
Q_D(const QGraphicsGridLayout);
if (index < 0 || index >= d->engine.itemCount()) {
qWarning("QGraphicsGridLayout::itemAt: invalid index %d", index);
return 0;
return nullptr;
}
QGraphicsLayoutItem *item = 0;
if (QGraphicsGridLayoutEngineItem *engineItem = static_cast<QGraphicsGridLayoutEngineItem*>(d->engine.itemAt(index)))
item = engineItem->layoutItem();
return item;
return engineItem->layoutItem();
return nullptr;
}
/*!

View File

@ -661,9 +661,9 @@
\value ItemSceneChange The item is moved to a new scene. This notification is
also sent when the item is added to its initial scene, and when it is removed.
The item's scene() is the old scene (or 0 if the item has not been added to a
scene yet). The value argument is the new scene (i.e., a QGraphicsScene
pointer), or a null pointer if the item is removed from a scene. Do not
The item's scene() is the old scene, or \nullptr if the item has not been added
to a scene yet. The value argument is the new scene (i.e., a QGraphicsScene
pointer), or \nullptr if the item is removed from a scene. Do not
override this change by passing this item to QGraphicsScene::addItem() as this
notification is delivered; instead, you can return the new scene from
itemChange(). Use this feature with caution; objecting to a scene change can
@ -1542,7 +1542,7 @@ void QGraphicsItemCache::purge()
Constructs a QGraphicsItem with the given \a parent item.
It does not modify the parent object returned by QObject::parent().
If \a parent is 0, you can add the item to a scene by calling
If \a parent is \nullptr, you can add the item to a scene by calling
QGraphicsScene::addItem(). The item will then become a top-level item.
\sa QGraphicsScene::addItem(), setParentItem()
@ -1650,8 +1650,8 @@ QGraphicsItem::~QGraphicsItem()
}
/*!
Returns the current scene for the item, or 0 if the item is not stored in
a scene.
Returns the current scene for the item, or \nullptr if the item is
not stored in a scene.
To add or move an item to a scene, call QGraphicsScene::addItem().
*/
@ -1661,15 +1661,15 @@ QGraphicsScene *QGraphicsItem::scene() const
}
/*!
Returns a pointer to this item's item group, or 0 if this item is not
member of a group.
Returns a pointer to this item's item group, or \nullptr if this
item is not member of a group.
\sa QGraphicsItemGroup, QGraphicsScene::createItemGroup()
*/
QGraphicsItemGroup *QGraphicsItem::group() const
{
if (!d_ptr->isMemberOfGroup)
return 0;
return nullptr;
QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);
while ((parent = parent->d_ptr->parent)) {
if (QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(parent))
@ -1677,11 +1677,11 @@ QGraphicsItemGroup *QGraphicsItem::group() const
}
// Unreachable; if d_ptr->isMemberOfGroup is != 0, then one parent of this
// item is a group item.
return 0;
return nullptr;
}
/*!
Adds this item to the item group \a group. If \a group is 0, this item is
Adds this item to the item group \a group. If \a group is \nullptr, this item is
removed from any current group and added as a child of the previous
group's parent.
@ -1699,7 +1699,7 @@ void QGraphicsItem::setGroup(QGraphicsItemGroup *group)
/*!
Returns a pointer to this item's parent item. If this item does not have a
parent, 0 is returned.
parent, \nullptr is returned.
\sa setParentItem(), childItems()
*/
@ -1710,8 +1710,9 @@ QGraphicsItem *QGraphicsItem::parentItem() const
/*!
Returns this item's top-level item. The top-level item is the item's
topmost ancestor item whose parent is 0. If an item has no parent, its own
pointer is returned (i.e., a top-level item is its own top-level item).
topmost ancestor item whose parent is \nullptr. If an item has no
parent, its own pointer is returned (i.e., a top-level item is its
own top-level item).
\sa parentItem()
*/
@ -1734,7 +1735,7 @@ QGraphicsItem *QGraphicsItem::topLevelItem() const
QGraphicsObject *QGraphicsItem::parentObject() const
{
QGraphicsItem *p = d_ptr->parent;
return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0;
return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : nullptr;
}
/*!
@ -1757,23 +1758,24 @@ QGraphicsWidget *QGraphicsItem::parentWidget() const
\since 4.4
Returns a pointer to the item's top level widget (i.e., the item's
ancestor whose parent is 0, or whose parent is not a widget), or 0 if this
item does not have a top level widget. If the item is its own top level
widget, this function returns a pointer to the item itself.
ancestor whose parent is \nullptr, or whose parent is not a widget), or
\nullptr if this item does not have a top level widget. If the item
is its own top level widget, this function returns a pointer to the
item itself.
*/
QGraphicsWidget *QGraphicsItem::topLevelWidget() const
{
if (const QGraphicsWidget *p = parentWidget())
return p->topLevelWidget();
return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0;
return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : nullptr;
}
/*!
\since 4.4
Returns the item's window, or 0 if this item does not have a window. If
the item is a window, it will return itself. Otherwise it will return the
closest ancestor that is a window.
Returns the item's window, or \nullptr if this item does not have a
window. If the item is a window, it will return itself. Otherwise
it will return the closest ancestor that is a window.
\sa QGraphicsWidget::isWindow()
*/
@ -1782,15 +1784,15 @@ QGraphicsWidget *QGraphicsItem::window() const
QGraphicsItem *p = panel();
if (p && p->isWindow())
return static_cast<QGraphicsWidget *>(p);
return 0;
return nullptr;
}
/*!
\since 4.6
Returns the item's panel, or 0 if this item does not have a panel. If the
item is a panel, it will return itself. Otherwise it will return the
closest ancestor that is a panel.
Returns the item's panel, or \nullptr if this item does not have a
panel. If the item is a panel, it will return itself. Otherwise it
will return the closest ancestor that is a panel.
\sa isPanel(), ItemIsPanel
*/
@ -1798,7 +1800,7 @@ QGraphicsItem *QGraphicsItem::panel() const
{
if (d_ptr->flags & ItemIsPanel)
return const_cast<QGraphicsItem *>(this);
return d_ptr->parent ? d_ptr->parent->panel() : 0;
return d_ptr->parent ? d_ptr->parent->panel() : nullptr;
}
/*!
@ -2397,7 +2399,7 @@ bool QGraphicsItem::isVisible() const
/*!
\since 4.4
Returns \c true if the item is visible to \a parent; otherwise, false is
returned. \a parent can be 0, in which case this function will return
returned. \a parent can be \nullptr, in which case this function will return
whether the item is visible to the scene or not.
An item may not be visible to its ancestors even if isVisible() is true. It
@ -2925,7 +2927,7 @@ void QGraphicsItem::setOpacity(qreal opacity)
}
/*!
Returns a pointer to this item's effect if it has one; otherwise 0.
Returns a pointer to this item's effect if it has one; otherwise \nullptr.
\since 4.6
*/
@ -2939,7 +2941,7 @@ QGraphicsEffect *QGraphicsItem::graphicsEffect() const
Sets \a effect as the item's effect. If there already is an effect installed
on this item, QGraphicsItem will delete the existing effect before installing
the new \a effect. You can delete an existing effect by calling
setGraphicsEffect(0).
setGraphicsEffect(\nullptr).
If \a effect is the installed effect on a different item, setGraphicsEffect() will remove
the effect from the item and install it on this item.
@ -3577,7 +3579,7 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenB
/*!
\since 4.6
Returns this item's focus proxy, or 0 if this item has no
Returns this item's focus proxy, or \nullptr if this item has no
focus proxy.
\sa setFocusProxy(), setFocus(), hasFocus()
@ -3640,7 +3642,7 @@ void QGraphicsItem::setFocusProxy(QGraphicsItem *item)
If this item, a child or descendant of this item currently has input
focus, this function will return a pointer to that item. If
no descendant has input focus, 0 is returned.
no descendant has input focus, \nullptr is returned.
\sa hasFocus(), setFocus(), QWidget::focusWidget()
*/
@ -3995,6 +3997,7 @@ void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin)
ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin).
*/
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
@ -4010,6 +4013,7 @@ QMatrix QGraphicsItem::matrix() const
{
return transform().toAffine();
}
#endif
/*!
\since 4.3
@ -4320,6 +4324,7 @@ void QGraphicsItem::setTransformOriginPoint(const QPointF &origin)
*/
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
@ -4332,7 +4337,7 @@ QMatrix QGraphicsItem::sceneMatrix() const
d_ptr->ensureSceneTransform();
return d_ptr->sceneTransform.toAffine();
}
#endif
/*!
\since 4.3
@ -4544,6 +4549,7 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
return x;
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
@ -4582,6 +4588,7 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
// Send post-notification.
itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform));
}
#endif
/*!
\since 4.3
@ -4636,6 +4643,7 @@ void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)
d_ptr->sendScenePosChange();
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
@ -4645,6 +4653,7 @@ void QGraphicsItem::resetMatrix()
{
resetTransform();
}
#endif
/*!
\since 4.3
@ -5790,7 +5799,7 @@ void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem
/*!
\internal
Sets the focusProxy pointer to 0 for all items that have this item as their
Sets the focusProxy pointer to \nullptr for all items that have this item as their
focusProxy.
*/
void QGraphicsItemPrivate::resetFocusProxy()
@ -6001,7 +6010,7 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
Maps the point \a point, which is in this item's coordinate system, to \a
item's coordinate system, and returns the mapped coordinate.
If \a item is 0, this function returns the same as mapToScene().
If \a item is \nullptr, this function returns the same as mapToScene().
\sa itemTransform(), mapToParent(), mapToScene(), transform(), mapFromItem(), {The Graphics
View Coordinate System}
@ -6071,7 +6080,7 @@ QPointF QGraphicsItem::mapToScene(const QPointF &point) const
Maps the rectangle \a rect, which is in this item's coordinate system, to
\a item's coordinate system, and returns the mapped rectangle as a polygon.
If \a item is 0, this function returns the same as mapToScene().
If \a item is \nullptr, this function returns the same as mapToScene().
\sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
Graphics View Coordinate System}
@ -6142,7 +6151,7 @@ QPolygonF QGraphicsItem::mapToScene(const QRectF &rect) const
\a item's coordinate system, and returns the mapped rectangle as a new
rectangle (i.e., the bounding rectangle of the resulting polygon).
If \a item is 0, this function returns the same as mapRectToScene().
If \a item is \nullptr, this function returns the same as mapRectToScene().
\sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
Graphics View Coordinate System}
@ -6217,7 +6226,7 @@ QRectF QGraphicsItem::mapRectToScene(const QRectF &rect) const
this item's coordinate system, and returns the mapped rectangle as a new
rectangle (i.e., the bounding rectangle of the resulting polygon).
If \a item is 0, this function returns the same as mapRectFromScene().
If \a item is \nullptr, this function returns the same as mapRectFromScene().
\sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
Graphics View Coordinate System}
@ -6290,7 +6299,7 @@ QRectF QGraphicsItem::mapRectFromScene(const QRectF &rect) const
Maps the polygon \a polygon, which is in this item's coordinate system, to
\a item's coordinate system, and returns the mapped polygon.
If \a item is 0, this function returns the same as mapToScene().
If \a item is \nullptr, this function returns the same as mapToScene().
\sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
Graphics View Coordinate System}
@ -6337,7 +6346,7 @@ QPolygonF QGraphicsItem::mapToScene(const QPolygonF &polygon) const
Maps the path \a path, which is in this item's coordinate system, to
\a item's coordinate system, and returns the mapped path.
If \a item is 0, this function returns the same as mapToScene().
If \a item is \nullptr, this function returns the same as mapToScene().
\sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
Graphics View Coordinate System}
@ -6384,7 +6393,7 @@ QPainterPath QGraphicsItem::mapToScene(const QPainterPath &path) const
Maps the point \a point, which is in \a item's coordinate system, to this
item's coordinate system, and returns the mapped coordinate.
If \a item is 0, this function returns the same as mapFromScene().
If \a item is \nullptr, this function returns the same as mapFromScene().
\sa itemTransform(), mapFromParent(), mapFromScene(), transform(), mapToItem(), {The Graphics
View Coordinate System}
@ -6456,7 +6465,7 @@ QPointF QGraphicsItem::mapFromScene(const QPointF &point) const
this item's coordinate system, and returns the mapped rectangle as a
polygon.
If \a item is 0, this function returns the same as mapFromScene()
If \a item is \nullptr, this function returns the same as mapFromScene()
\sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The Graphics View Coordinate
System}
@ -6524,7 +6533,7 @@ QPolygonF QGraphicsItem::mapFromScene(const QRectF &rect) const
Maps the polygon \a polygon, which is in \a item's coordinate system, to
this item's coordinate system, and returns the mapped polygon.
If \a item is 0, this function returns the same as mapFromScene().
If \a item is \nullptr, this function returns the same as mapFromScene().
\sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The
Graphics View Coordinate System}
@ -6569,7 +6578,7 @@ QPolygonF QGraphicsItem::mapFromScene(const QPolygonF &polygon) const
Maps the path \a path, which is in \a item's coordinate system, to
this item's coordinate system, and returns the mapped path.
If \a item is 0, this function returns the same as mapFromScene().
If \a item is \nullptr, this function returns the same as mapFromScene().
\sa itemTransform(), mapFromParent(), mapFromScene(), mapToItem(), {The
Graphics View Coordinate System}
@ -6633,15 +6642,15 @@ bool QGraphicsItem::isAncestorOf(const QGraphicsItem *child) const
/*!
\since 4.4
Returns the closest common ancestor item of this item and \a other, or 0
if either \a other is 0, or there is no common ancestor.
Returns the closest common ancestor item of this item and \a other,
or \nullptr if either \a other is \nullptr, or there is no common ancestor.
\sa isAncestorOf()
*/
QGraphicsItem *QGraphicsItem::commonAncestorItem(const QGraphicsItem *other) const
{
if (!other)
return 0;
return nullptr;
if (other == this)
return const_cast<QGraphicsItem *>(this);
const QGraphicsItem *thisw = this;
@ -6726,7 +6735,7 @@ void QGraphicsItem::setData(int key, const QVariant &value)
\since 4.2
Returns the given \a item cast to type T if \a item is of type T;
otherwise, 0 is returned.
otherwise, \nullptr is returned.
\note To make this function work correctly with custom items, reimplement
the \l{QGraphicsItem::}{type()} function for each custom QGraphicsItem

View File

@ -283,10 +283,16 @@ public:
inline void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xmargin = 50, int ymargin = 50);
// Local transformation
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use transform() instead")
QMatrix matrix() const;
QT_DEPRECATED_X("Use sceneTransform() instead")
QMatrix sceneMatrix() const;
QT_DEPRECATED_X("Use setTransform() instead")
void setMatrix(const QMatrix &matrix, bool combine = false);
QT_DEPRECATED_X("Use resetTransform() instead")
void resetMatrix();
#endif
QTransform transform() const;
QTransform sceneTransform() const;
QTransform deviceTransform(const QTransform &viewportTransform) const;

View File

@ -549,6 +549,7 @@ void QGraphicsItemAnimation::setStep(qreal step)
afterAnimationStep(step);
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
Resets the item to its starting position and transformation.
@ -563,6 +564,7 @@ void QGraphicsItemAnimation::reset()
d->startPos = d->item->pos();
d->startMatrix = d->item->matrix();
}
#endif
/*!
\fn void QGraphicsItemAnimation::beforeAnimationStep(qreal step)

View File

@ -96,7 +96,10 @@ public:
public Q_SLOTS:
void setStep(qreal x);
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use setStep(0) instead")
void reset();
#endif
protected:
virtual void beforeAnimationStep(qreal step);

View File

@ -193,7 +193,7 @@ QSizeF *QGraphicsLayoutItemPrivate::effectiveSizeHints(const QSizeF &constraint)
/*!
\internal
Returns the parent item of this layout, or 0 if this layout is
Returns the parent item of this layout, or \nullptr if this layout is
not installed on any widget.
If this is the item that the layout is installed on, it will return "itself".
@ -214,7 +214,7 @@ QGraphicsItem *QGraphicsLayoutItemPrivate::parentItem() const
while (parent && parent->isLayout()) {
parent = parent->parentLayoutItem();
}
return parent ? parent->graphicsItem() : 0;
return parent ? parent->graphicsItem() : nullptr;
}
/*!
@ -368,7 +368,7 @@ bool QGraphicsLayoutItemPrivate::hasWidthForHeight() const
passing a QGraphicsLayoutItem pointer to QGraphicsLayoutItem's
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
parent. If the item's parent is \nullptr or if the parent does not inherit
from QGraphicsItem, the parentLayoutItem() function then returns \nullptr.
isLayout() returns \c true if the QGraphicsLayoutItem subclass is itself a
layout, or false otherwise.
@ -737,7 +737,7 @@ QRectF QGraphicsLayoutItem::geometry() const
This virtual function provides the \a left, \a top, \a right and \a bottom
contents margins for this QGraphicsLayoutItem. The default implementation
assumes all contents margins are 0. The parameters point to values stored
in qreals. If any of the pointers is 0, that value will not be updated.
in qreals. If any of the pointers is \nullptr, that value will not be updated.
\sa QGraphicsWidget::setContentsMargins()
*/
@ -826,8 +826,8 @@ void QGraphicsLayoutItem::updateGeometry()
}
/*!
Returns the parent of this QGraphicsLayoutItem, or 0 if there is no parent,
or if the parent does not inherit from QGraphicsLayoutItem
Returns the parent of this QGraphicsLayoutItem, or \nullptr if there is
no parent, or if the parent does not inherit from QGraphicsLayoutItem
(QGraphicsLayoutItem is often used through multiple inheritance with
QObject-derived classes).
@ -917,7 +917,7 @@ QGraphicsItem *QGraphicsLayoutItem::graphicsItem() const
* advantage of the automatic reparenting capabilities of QGraphicsLayout it
* should set this value.
* Note that if you delete \a item and not delete the layout item, you are
* responsible of calling setGraphicsItem(0) in order to avoid having a
* responsible of calling setGraphicsItem(\nullptr) in order to avoid having a
* dangling pointer.
*
* \sa graphicsItem()

View File

@ -556,7 +556,7 @@ QGraphicsProxyWidget::~QGraphicsProxyWidget()
exclusively either inside or outside of Graphics View. You cannot embed a
widget as long as it is is visible elsewhere in the UI, at the same time.
\a widget must be a top-level widget whose parent is 0.
\a widget must be a top-level widget whose parent is \nullptr.
When the widget is embedded, its state (e.g., visible, enabled, geometry,
size hints) is copied into the proxy widget. If the embedded widget is
@ -739,7 +739,7 @@ QWidget *QGraphicsProxyWidget::widget() const
Returns the rectangle for \a widget, which must be a descendant of
widget(), or widget() itself, in this proxy item's local coordinates.
If no widget is embedded, \a widget is 0, or \a widget is not a
If no widget is embedded, \a widget is \nullptr, or \a widget is not a
descendant of the embedded widget, this function returns an empty QRectF.
\sa widget()

View File

@ -1929,6 +1929,7 @@ void QGraphicsScene::setBspTreeDepth(int depth)
bspTree->setBspTreeDepth(depth);
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\property QGraphicsScene::sortCacheEnabled
\brief whether sort caching is enabled
@ -1949,6 +1950,7 @@ void QGraphicsScene::setSortCacheEnabled(bool enabled)
return;
d->sortCacheEnabled = enabled;
}
#endif
/*!
Calculates and returns the bounding rect of all items on the scene. This
@ -2144,8 +2146,8 @@ QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item,
\overload
\obsolete
Returns the topmost visible item at the specified \a position, or 0 if
there are no items at this position.
Returns the topmost visible item at the specified \a position, or
\nullptr if there are no items at this position.
This function is deprecated and returns incorrect results if the scene
contains items that ignore transformations. Use the overload that takes
@ -2159,7 +2161,7 @@ QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item,
/*!
\since 4.6
Returns the topmost visible item at the specified \a position, or 0
Returns the topmost visible item at the specified \a position, or \nullptr
if there are no items at this position.
\a deviceTransform is the transformation that applies to the view, and needs to
@ -2173,7 +2175,7 @@ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform
{
const QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape,
Qt::DescendingOrder, deviceTransform);
return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();
return itemsAtPoint.isEmpty() ? nullptr : itemsAtPoint.first();
}
/*!
@ -2182,7 +2184,7 @@ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform
\since 4.6
Returns the topmost visible item at the position specified by (\a x, \a
y), or 0 if there are no items at this position.
y), or \nullptr if there are no items at this position.
\a deviceTransform is the transformation that applies to the view, and needs to
be provided if the scene contains items that ignore transformations.
@ -2199,7 +2201,7 @@ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform
\obsolete
Returns the topmost visible item at the position specified by (\a x, \a
y), or 0 if there are no items at this position.
y), or \nullptr if there are no items at this position.
This convenience function is equivalent to calling \c
{itemAt(QPointF(x, y))}.
@ -2941,9 +2943,9 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
/*!
When the scene is active, this functions returns the scene's current focus
item, or 0 if no item currently has focus. When the scene is inactive, this
functions returns the item that will gain input focus when the scene becomes
active.
item, or \nullptr if no item currently has focus. When the scene is inactive,
this functions returns the item that will gain input focus when the scene
becomes active.
The focus item receives keyboard input when the scene receives a
key event.
@ -2961,12 +2963,12 @@ QGraphicsItem *QGraphicsScene::focusItem() const
focusReason, after removing focus from any previous item that may have had
focus.
If \a item is 0, or if it either does not accept focus (i.e., it does not
If \a item is \nullptr, or if it either does not accept focus (i.e., it does not
have the QGraphicsItem::ItemIsFocusable flag enabled), or is not visible
or not enabled, this function only removes focus from any previous
focusitem.
If item is not 0, and the scene does not currently have focus (i.e.,
If item is not \nullptr, and the scene does not currently have focus (i.e.,
hasFocus() returns \c false), this function will call setFocus()
automatically.
@ -3062,9 +3064,9 @@ bool QGraphicsScene::stickyFocus() const
}
/*!
Returns the current mouse grabber item, or 0 if no item is currently
grabbing the mouse. The mouse grabber item is the item that receives all
mouse events sent to the scene.
Returns the current mouse grabber item, or \nullptr if no item is
currently grabbing the mouse. The mouse grabber item is the item
that receives all mouse events sent to the scene.
An item becomes a mouse grabber when it receives and accepts a
mouse press event, and it stays the mouse grabber until either of
@ -5547,7 +5549,7 @@ bool QGraphicsScene::focusNextPrevChild(bool next)
\a oldFocusItem is a pointer to the item that previously had focus, or
0 if no item had focus before the signal was emitted. \a newFocusItem
is a pointer to the item that gained input focus, or 0 if focus was lost.
is a pointer to the item that gained input focus, or \nullptr if focus was lost.
\a reason is the reason for the focus change (e.g., if the scene was
deactivated while an input field had focus, \a oldFocusItem would point
to the input field item, \a newFocusItem would be 0, and \a reason would be
@ -5582,7 +5584,7 @@ QStyle *QGraphicsScene::style() const
the style for all widgets in the scene that do not have a style explicitly
assigned to them.
If \a style is 0, QGraphicsScene will revert to QApplication::style().
If \a style is \nullptr, QGraphicsScene will revert to QApplication::style().
\sa style()
*/
@ -5703,7 +5705,8 @@ bool QGraphicsScene::isActive() const
/*!
\since 4.6
Returns the current active panel, or 0 if no panel is currently active.
Returns the current active panel, or \nullptr if no panel is
currently active.
\sa QGraphicsScene::setActivePanel()
*/
@ -5720,7 +5723,7 @@ QGraphicsItem *QGraphicsScene::activePanel() const
deactivate any currently active panel.
If the scene is currently inactive, \a item remains inactive until the
scene becomes active (or, ir \a item is 0, no item will be activated).
scene becomes active (or, ir \a item is \nullptr, no item will be activated).
\sa activePanel(), isActive(), QGraphicsItem::isActive()
*/
@ -5733,8 +5736,8 @@ void QGraphicsScene::setActivePanel(QGraphicsItem *item)
/*!
\since 4.4
Returns the current active window, or 0 if no window is currently
active.
Returns the current active window, or \nullptr if no window is
currently active.
\sa QGraphicsScene::setActiveWindow()
*/
@ -5743,7 +5746,7 @@ QGraphicsWidget *QGraphicsScene::activeWindow() const
Q_D(const QGraphicsScene);
if (d->activePanel && d->activePanel->isWindow())
return static_cast<QGraphicsWidget *>(d->activePanel);
return 0;
return nullptr;
}
/*!

View File

@ -141,8 +141,10 @@ public:
ItemIndexMethod itemIndexMethod() const;
void setItemIndexMethod(ItemIndexMethod method);
bool isSortCacheEnabled() const;
void setSortCacheEnabled(bool enabled);
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED bool isSortCacheEnabled() const;
QT_DEPRECATED void setSortCacheEnabled(bool enabled);
#endif
int bspTreeDepth() const;
void setBspTreeDepth(int depth);

View File

@ -319,8 +319,8 @@ QGraphicsSceneEvent::~QGraphicsSceneEvent()
}
/*!
Returns the widget where the event originated, or 0 if the event
originates from another application.
Returns the widget where the event originated, or \nullptr if the
event originates from another application.
*/
QWidget *QGraphicsSceneEvent::widget() const
{

View File

@ -1676,7 +1676,7 @@ void QGraphicsView::setInteractive(bool allowed)
/*!
Returns a pointer to the scene that is currently visualized in the
view. If no scene is currently visualized, 0 is returned.
view. If no scene is currently visualized, \nullptr is returned.
\sa setScene()
*/

View File

@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE
manage the relationships between parent and child items. These functions
control the stacking order of items as well as their ownership.
\note The QObject::parent() should always return 0 for QGraphicsWidgets,
\note The QObject::parent() should always return \nullptr for QGraphicsWidgets,
but this policy is not strictly defined.
\sa QGraphicsProxyWidget, QGraphicsItem, {Widgets and Layouts}
@ -518,7 +518,7 @@ void QGraphicsWidget::setContentsMargins(qreal left, qreal top, qreal right, qre
/*!
Gets the widget's contents margins. The margins are stored in \a left, \a
top, \a right and \a bottom, as pointers to qreals. Each argument can
be \e {omitted} by passing 0.
be \e {omitted} by passing \nullptr.
\sa setContentsMargins()
*/
@ -573,7 +573,7 @@ void QGraphicsWidget::setWindowFrameMargins(qreal left, qreal top, qreal right,
/*!
Gets the widget's window frame margins. The margins are stored in \a left,
\a top, \a right and \a bottom as pointers to qreals. Each argument can
be \e {omitted} by passing 0.
be \e {omitted} by passing \nullptr.
\sa setWindowFrameMargins(), windowFrameRect()
*/
@ -780,7 +780,7 @@ QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
\brief The layout of the widget
Any existing layout manager is deleted before the new layout is assigned. If
\a layout is 0, the widget is left without a layout. Existing subwidgets'
\a layout is \nullptr, the widget is left without a layout. Existing subwidgets'
geometries will remain unaffected.
QGraphicsWidget takes ownership of \a layout.
@ -792,7 +792,7 @@ QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
explicitly managed by \a layout remain unaffected by the layout after
it has been assigned to this widget.
If no layout is currently managing this widget, layout() will return 0.
If no layout is currently managing this widget, layout() will return \nullptr.
*/
@ -803,8 +803,8 @@ QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
*/
/*!
Returns this widget's layout, or 0 if no layout is currently managing this
widget.
Returns this widget's layout, or \nullptr if no layout is currently
managing this widget.
\sa setLayout()
*/
@ -818,7 +818,7 @@ QGraphicsLayout *QGraphicsWidget::layout() const
\fn void QGraphicsWidget::setLayout(QGraphicsLayout *layout)
Sets the layout for this widget to \a layout. Any existing layout manager
is deleted before the new layout is assigned. If \a layout is 0, the
is deleted before the new layout is assigned. If \a layout is \nullptr, the
widget is left without a layout. Existing subwidgets' geometries will
remain unaffected.
@ -937,11 +937,11 @@ QStyle *QGraphicsWidget::style() const
Sets the widget's style to \a style. QGraphicsWidget does \e not take
ownership of \a style.
If no style is assigned, or \a style is 0, the widget will use
If no style is assigned, or \a style is \nullptr, the widget will use
QGraphicsScene::style() (if this has been set). Otherwise the widget will
use QApplication::style().
This function sets the Qt::WA_SetStyle attribute if \a style is not 0;
This function sets the Qt::WA_SetStyle attribute if \a style is not \nullptr;
otherwise it clears the attribute.
\sa style()
@ -1871,7 +1871,7 @@ void QGraphicsWidget::setFocusPolicy(Qt::FocusPolicy policy)
/*!
If this widget, a child or descendant of this widget currently has input
focus, this function will return a pointer to that widget. If
no descendant widget has input focus, 0 is returned.
no descendant widget has input focus, \nullptr is returned.
\sa QGraphicsItem::focusItem(), QWidget::focusWidget()
*/
@ -1880,7 +1880,7 @@ QGraphicsWidget *QGraphicsWidget::focusWidget() const
Q_D(const QGraphicsWidget);
if (d->subFocusItem && d->subFocusItem->d_ptr->isWidget)
return static_cast<QGraphicsWidget *>(d->subFocusItem);
return 0;
return nullptr;
}
#ifndef QT_NO_SHORTCUT
@ -2022,7 +2022,7 @@ void QGraphicsWidget::addActions(QList<QAction *> actions)
\since 4.5
Inserts the action \a action to this widget's list of actions,
before the action \a before. It appends the action if \a before is 0 or
before the action \a before. It appends the action if \a before is \nullptr or
\a before is not a valid action for this widget.
A QGraphicsWidget should only have one of each action.
@ -2062,7 +2062,7 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action)
\since 4.5
Inserts the actions \a actions to this widget's list of actions,
before the action \a before. It appends the action if \a before is 0 or
before the action \a before. It appends the action if \a before is \nullptr or
\a before is not a valid action for this widget.
A QGraphicsWidget can have at most one of each action.
@ -2131,9 +2131,9 @@ QList<QAction *> QGraphicsWidget::actions() const
\snippet code/src_gui_graphicsview_qgraphicswidget.cpp 2
If \a first is 0, this indicates that \a second should be the first widget
If \a first is \nullptr, this indicates that \a second should be the first widget
to receive input focus should the scene gain Tab focus (i.e., the user
hits Tab so that focus passes into the scene). If \a second is 0, this
hits Tab so that focus passes into the scene). If \a second is \nullptr, this
indicates that \a first should be the first widget to gain focus if the
scene gained BackTab focus.

View File

@ -345,6 +345,7 @@ bool QAbstractItemDelegate::editorEvent(QEvent *,
return false;
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
@ -364,6 +365,7 @@ QString QAbstractItemDelegate::elidedText(const QFontMetrics &fontMetrics, int w
{
return fontMetrics.elidedText(text, mode, width);
}
#endif
/*!
\since 4.3

View File

@ -103,8 +103,11 @@ public:
const QStyleOptionViewItem &option,
const QModelIndex &index);
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use QFontMetrics::elidedText() instead")
static QString elidedText(const QFontMetrics &fontMetrics, int width,
Qt::TextElideMode mode, const QString &text);
#endif
virtual bool helpEvent(QHelpEvent *event,
QAbstractItemView *view,

View File

@ -940,8 +940,8 @@ void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *de
\since 4.2
Returns the item delegate used by this view and model for the given \a row,
or 0 if no delegate has been assigned. You can call itemDelegate() to get a
pointer to the current delegate for a given index.
or \nullptr if no delegate has been assigned. You can call itemDelegate()
to get a pointer to the current delegate for a given index.
\sa setItemDelegateForRow(), itemDelegateForColumn(), setItemDelegate()
*/
@ -2921,6 +2921,7 @@ void QAbstractItemView::editorDestroyed(QObject *editor)
setState(NoState);
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
Sets the horizontal scroll bar's steps per item to \a steps.
@ -2978,6 +2979,7 @@ int QAbstractItemView::verticalStepsPerItem() const
{
return 1;
}
#endif
/*!
Moves to and selects the item best matching the string \a search.

View File

@ -272,10 +272,12 @@ Q_SIGNALS:
protected:
QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = nullptr);
void setHorizontalStepsPerItem(int steps);
int horizontalStepsPerItem() const;
void setVerticalStepsPerItem(int steps);
int verticalStepsPerItem() const;
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED void setHorizontalStepsPerItem(int steps);
QT_DEPRECATED int horizontalStepsPerItem() const;
QT_DEPRECATED void setVerticalStepsPerItem(int steps);
QT_DEPRECATED int verticalStepsPerItem() const;
#endif
enum CursorAction { MoveUp, MoveDown, MoveLeft, MoveRight,
MoveHome, MoveEnd, MovePageUp, MovePageDown,

View File

@ -801,7 +801,7 @@ void QColumnView::initializeColumn(QAbstractItemView *column) const
}
/*!
Returns the preview widget, or 0 if there is none.
Returns the preview widget, or \nullptr if there is none.
\sa setPreviewWidget(), updatePreviewWidget()
*/

View File

@ -724,8 +724,8 @@ void QItemDelegate::drawDecoration(QPainter *painter, const QStyleOptionViewItem
QPoint p = QStyle::alignedRect(option.direction, option.decorationAlignment,
pixmap.size(), rect).topLeft();
if (option.state & QStyle::State_Selected) {
QPixmap *pm = selected(pixmap, option.palette, option.state & QStyle::State_Enabled);
painter->drawPixmap(p, *pm);
const QPixmap pm = selectedPixmap(pixmap, option.palette, option.state & QStyle::State_Enabled);
painter->drawPixmap(p, pm);
} else {
painter->drawPixmap(p, pixmap);
}
@ -1001,17 +1001,29 @@ static QString qPixmapSerial(quint64 i, bool enabled)
return QString((const QChar *)ptr, int(&arr[sizeof(arr) / sizeof(ushort)] - ptr));
}
#if QT_DEPRECATED_SINCE(5, 13)
QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const
{
const QString key = qPixmapSerial(pixmap.cacheKey(), enabled);
QPixmap *pm = QPixmapCache::find(key);
if (pm)
return pm;
selectedPixmap(pixmap, palette, enabled);
return QPixmapCache::find(key);
}
#endif
/*!
\internal
Returns the selected version of the given \a pixmap using the given \a palette.
The \a enabled argument decides whether the normal or disabled highlight color of
the palette is used.
*/
QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const
QPixmap QItemDelegate::selectedPixmap(const QPixmap &pixmap, const QPalette &palette, bool enabled)
{
QString key = qPixmapSerial(pixmap.cacheKey(), enabled);
QPixmap *pm = QPixmapCache::find(key);
if (!pm) {
const QString key = qPixmapSerial(pixmap.cacheKey(), enabled);
QPixmap pm;
if (!QPixmapCache::find(key, &pm)) {
QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
QColor color = palette.color(enabled ? QPalette::Normal : QPalette::Disabled,
@ -1023,13 +1035,12 @@ QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette,
painter.fillRect(0, 0, img.width(), img.height(), color);
painter.end();
QPixmap selected = QPixmap(QPixmap::fromImage(img));
int n = (img.sizeInBytes() >> 10) + 1;
pm = QPixmap(QPixmap::fromImage(img));
const int n = (img.sizeInBytes() >> 10) + 1;
if (QPixmapCache::cacheLimit() < n)
QPixmapCache::setCacheLimit(n);
QPixmapCache::insert(key, selected);
pm = QPixmapCache::find(key);
QPixmapCache::insert(key, pm);
}
return pm;
}

View File

@ -113,7 +113,12 @@ protected:
const QStyleOptionViewItem &option) const;
QPixmap decoration(const QStyleOptionViewItem &option, const QVariant &variant) const;
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use selectedPixmap() instead")
QPixmap *selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const;
#endif
static QPixmap selectedPixmap(const QPixmap &pixmap, const QPalette &palette, bool enabled);
QRect doCheck(const QStyleOptionViewItem &option, const QRect &bounding,
const QVariant &variant) const;

View File

@ -138,20 +138,21 @@ void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height)
}
/** \internal
* \return a spans that spans over cell x,y (column,row) or 0 if there is none.
* \return a spans that spans over cell x,y (column,row)
* or \nullptr if there is none.
*/
QSpanCollection::Span *QSpanCollection::spanAt(int x, int y) const
{
Index::const_iterator it_y = index.lowerBound(-y);
if (it_y == index.end())
return 0;
return nullptr;
SubIndex::const_iterator it_x = (*it_y).lowerBound(-x);
if (it_x == (*it_y).end())
return 0;
return nullptr;
Span *span = *it_x;
if (span->right() >= x && span->bottom() >= y)
return span;
return 0;
return nullptr;
}

Some files were not shown because too many files have changed in this diff Show More