Use QList instead of QVector in examples

Task-number: QTBUG-84469
Change-Id: Id14119168bb1bf11f99bda7ef6ee9cf51bcfab2e
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
This commit is contained in:
Jarek Kobus 2020-06-22 10:12:38 +02:00
parent d7efb2a419
commit 29c99bddbf
82 changed files with 156 additions and 158 deletions

View File

@ -54,9 +54,9 @@
#include <QIODevice> #include <QIODevice>
#include <QPair> #include <QPair>
#include <QVariant> #include <QVariant>
#include <QVector> #include <QList>
class VariantOrderedMap : public QVector<QPair<QVariant, QVariant>> class VariantOrderedMap : public QList<QPair<QVariant, QVariant>>
{ {
public: public:
VariantOrderedMap() = default; VariantOrderedMap() = default;

View File

@ -58,12 +58,12 @@
#include <stdio.h> #include <stdio.h>
static QVector<Converter *> *availableConverters; static QList<Converter *> *availableConverters;
Converter::Converter() Converter::Converter()
{ {
if (!availableConverters) if (!availableConverters)
availableConverters = new QVector<Converter *>; availableConverters = new QList<Converter *>;
availableConverters->append(this); availableConverters->append(this);
} }

View File

@ -77,7 +77,7 @@
\snippet serialization/savegame/level.h 0 \snippet serialization/savegame/level.h 0
We want to have several levels in our game, each with several NPCs, so we We want to have several levels in our game, each with several NPCs, so we
keep a QVector of Character objects. We also provide the familiar read() and keep a QList of Character objects. We also provide the familiar read() and
write() functions. write() functions.
\snippet serialization/savegame/level.cpp 0 \snippet serialization/savegame/level.cpp 0

View File

@ -63,7 +63,7 @@ Character Game::player() const
return mPlayer; return mPlayer;
} }
QVector<Level> Game::levels() const QList<Level> Game::levels() const
{ {
return mLevels; return mLevels;
} }
@ -80,7 +80,7 @@ void Game::newGame()
mLevels.reserve(2); mLevels.reserve(2);
Level village(QStringLiteral("Village")); Level village(QStringLiteral("Village"));
QVector<Character> villageNpcs; QList<Character> villageNpcs;
villageNpcs.reserve(2); villageNpcs.reserve(2);
villageNpcs.append(Character(QStringLiteral("Barry the Blacksmith"), villageNpcs.append(Character(QStringLiteral("Barry the Blacksmith"),
QRandomGenerator::global()->bounded(8, 11), QRandomGenerator::global()->bounded(8, 11),
@ -92,7 +92,7 @@ void Game::newGame()
mLevels.append(village); mLevels.append(village);
Level dungeon(QStringLiteral("Dungeon")); Level dungeon(QStringLiteral("Dungeon"));
QVector<Character> dungeonNpcs; QList<Character> dungeonNpcs;
dungeonNpcs.reserve(3); dungeonNpcs.reserve(3);
dungeonNpcs.append(Character(QStringLiteral("Eric the Evil"), dungeonNpcs.append(Character(QStringLiteral("Eric the Evil"),
QRandomGenerator::global()->bounded(18, 26), QRandomGenerator::global()->bounded(18, 26),

View File

@ -52,7 +52,7 @@
#define GAME_H #define GAME_H
#include <QJsonObject> #include <QJsonObject>
#include <QVector> #include <QList>
#include "character.h" #include "character.h"
#include "level.h" #include "level.h"
@ -66,7 +66,7 @@ public:
}; };
Character player() const; Character player() const;
QVector<Level> levels() const; QList<Level> levels() const;
void newGame(); void newGame();
bool loadGame(SaveFormat saveFormat); bool loadGame(SaveFormat saveFormat);
@ -78,7 +78,7 @@ public:
void print(int indentation = 0) const; void print(int indentation = 0) const;
private: private:
Character mPlayer; Character mPlayer;
QVector<Level> mLevels; QList<Level> mLevels;
}; };
//! [0] //! [0]

View File

@ -62,12 +62,12 @@ QString Level::name() const
return mName; return mName;
} }
QVector<Character> Level::npcs() const QList<Character> Level::npcs() const
{ {
return mNpcs; return mNpcs;
} }
void Level::setNpcs(const QVector<Character> &npcs) void Level::setNpcs(const QList<Character> &npcs)
{ {
mNpcs = npcs; mNpcs = npcs;
} }

View File

@ -52,7 +52,7 @@
#define LEVEL_H #define LEVEL_H
#include <QJsonObject> #include <QJsonObject>
#include <QVector> #include <QList>
#include "character.h" #include "character.h"
@ -65,8 +65,8 @@ public:
QString name() const; QString name() const;
QVector<Character> npcs() const; QList<Character> npcs() const;
void setNpcs(const QVector<Character> &npcs); void setNpcs(const QList<Character> &npcs);
void read(const QJsonObject &json); void read(const QJsonObject &json);
void write(QJsonObject &json) const; void write(QJsonObject &json) const;
@ -74,7 +74,7 @@ public:
void print(int indentation = 0) const; void print(int indentation = 0) const;
private: private:
QString mName; QString mName;
QVector<Character> mNpcs; QList<Character> mNpcs;
}; };
//! [0] //! [0]

View File

@ -61,7 +61,7 @@ Message::Message(const QString &body, const QStringList &headers)
QDebug operator<<(QDebug dbg, const Message &message) QDebug operator<<(QDebug dbg, const Message &message)
{ {
const QString body = message.body(); const QString body = message.body();
QVector<QStringRef> pieces = body.splitRef(QLatin1String("\r\n"), Qt::SkipEmptyParts); QList<QStringRef> pieces = body.splitRef(QLatin1String("\r\n"), Qt::SkipEmptyParts);
if (pieces.isEmpty()) if (pieces.isEmpty())
dbg.nospace() << "Message()"; dbg.nospace() << "Message()";
else if (pieces.size() == 1) else if (pieces.size() == 1)

View File

@ -63,7 +63,7 @@ class DownloadManager: public QObject
{ {
Q_OBJECT Q_OBJECT
QNetworkAccessManager manager; QNetworkAccessManager manager;
QVector<QNetworkReply *> currentDownloads; QList<QNetworkReply *> currentDownloads;
public: public:
DownloadManager(); DownloadManager();

View File

@ -53,7 +53,7 @@
#include <QDialog> #include <QDialog>
#include <QString> #include <QString>
#include <QVector> #include <QList>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QLabel; class QLabel;
@ -76,7 +76,7 @@ private:
QLabel *statusLabel = nullptr; QLabel *statusLabel = nullptr;
QTcpServer *tcpServer = nullptr; QTcpServer *tcpServer = nullptr;
QVector<QString> fortunes; QList<QString> fortunes;
}; };
//! [0] //! [0]

View File

@ -148,7 +148,7 @@ bool GSuggestCompletion::eventFilter(QObject *obj, QEvent *ev)
//! [4] //! [4]
//! [5] //! [5]
void GSuggestCompletion::showCompletion(const QVector<QString> &choices) void GSuggestCompletion::showCompletion(const QList<QString> &choices)
{ {
if (choices.isEmpty()) if (choices.isEmpty())
return; return;
@ -210,7 +210,7 @@ void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply)
{ {
QUrl url = networkReply->url(); QUrl url = networkReply->url();
if (networkReply->error() == QNetworkReply::NoError) { if (networkReply->error() == QNetworkReply::NoError) {
QVector<QString> choices; QList<QString> choices;
QByteArray response(networkReply->readAll()); QByteArray response(networkReply->readAll());
QXmlStreamReader xml(response); QXmlStreamReader xml(response);

View File

@ -64,7 +64,7 @@ public:
explicit GSuggestCompletion(QLineEdit *parent = nullptr); explicit GSuggestCompletion(QLineEdit *parent = nullptr);
~GSuggestCompletion(); ~GSuggestCompletion();
bool eventFilter(QObject *obj, QEvent *ev) override; bool eventFilter(QObject *obj, QEvent *ev) override;
void showCompletion(const QVector<QString> &choices); void showCompletion(const QList<QString> &choices);
public slots: public slots:

View File

@ -52,7 +52,7 @@
#define CLIENT_H #define CLIENT_H
#include <QDialog> #include <QDialog>
#include <QVector> #include <QList>
#include <QSctpSocket> #include <QSctpSocket>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -81,7 +81,7 @@ private slots:
void writeDatagram(const QByteArray &ba); void writeDatagram(const QByteArray &ba);
private: private:
QVector<Consumer *> consumers; QList<Consumer *> consumers;
QSctpSocket *sctpSocket; QSctpSocket *sctpSocket;
QComboBox *hostCombo; QComboBox *hostCombo;

View File

@ -52,7 +52,7 @@
#define SERVER_H #define SERVER_H
#include <QDialog> #include <QDialog>
#include <QVector> #include <QList>
#include <QList> #include <QList>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -81,7 +81,7 @@ private slots:
void writeDatagram(QSctpSocket *to, const QByteArray &ba); void writeDatagram(QSctpSocket *to, const QByteArray &ba);
private: private:
QVector<Provider *> providers; QList<Provider *> providers;
QSctpServer *sctpServer; QSctpServer *sctpServer;
QList<QSctpSocket *> connections; QList<QSctpSocket *> connections;

View File

@ -52,7 +52,7 @@
#include <QMainWindow> #include <QMainWindow>
#include <QSharedPointer> #include <QSharedPointer>
#include <QVector> #include <QList>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -99,7 +99,7 @@ private:
Ui::MainWindow *ui = nullptr; Ui::MainWindow *ui = nullptr;
using AssocPtr = QSharedPointer<DtlsAssociation>; using AssocPtr = QSharedPointer<DtlsAssociation>;
QVector<AssocPtr> connections; QList<AssocPtr> connections;
QString nameTemplate; QString nameTemplate;
unsigned nextId = 0; unsigned nextId = 0;

View File

@ -53,7 +53,7 @@
#include <QDialog> #include <QDialog>
#include <QHostAddress> #include <QHostAddress>
#include <QVector> #include <QList>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -78,7 +78,7 @@ public:
private: private:
Ui::NicSelector *ui = nullptr; Ui::NicSelector *ui = nullptr;
QVector<QHostAddress> availableAddresses; QList<QHostAddress> availableAddresses;
}; };
#endif // NICSELECTOR_H #endif // NICSELECTOR_H

View File

@ -1086,7 +1086,7 @@ void TorrentClient::scheduleUploads()
// seeding, we sort by upload speed. Seeds are left out; there's // seeding, we sort by upload speed. Seeds are left out; there's
// no use in unchoking them. // no use in unchoking them.
QList<PeerWireClient *> allClients = d->connections; QList<PeerWireClient *> allClients = d->connections;
QVector<QPair<qint64, PeerWireClient *>> transferSpeeds; QList<QPair<qint64, PeerWireClient *>> transferSpeeds;
for (PeerWireClient *client : qAsConst(allClients)) { for (PeerWireClient *client : qAsConst(allClients)) {
if (client->state() == QAbstractSocket::ConnectedState if (client->state() == QAbstractSocket::ConnectedState
&& client->availablePieces().count(true) != d->pieceCount) { && client->availablePieces().count(true) != d->pieceCount) {
@ -1373,7 +1373,7 @@ void TorrentClient::requestMore(PeerWireClient *client)
int TorrentClient::requestBlocks(PeerWireClient *client, TorrentPiece *piece, int maxBlocks) int TorrentClient::requestBlocks(PeerWireClient *client, TorrentPiece *piece, int maxBlocks)
{ {
// Generate the list of incomplete blocks for this piece. // Generate the list of incomplete blocks for this piece.
QVector<int> bits; QList<int> bits;
int completedBlocksSize = piece->completedBlocks.size(); int completedBlocksSize = piece->completedBlocks.size();
for (int i = 0; i < completedBlocksSize; ++i) { for (int i = 0; i < completedBlocksSize; ++i) {
if (!piece->completedBlocks.testBit(i) && !piece->requestedBlocks.testBit(i)) if (!piece->completedBlocks.testBit(i) && !piece->requestedBlocks.testBit(i))

View File

@ -52,7 +52,7 @@
#define LOGO_H #define LOGO_H
#include <qopengl.h> #include <qopengl.h>
#include <QVector> #include <QList>
#include <QVector3D> #include <QVector3D>
class Logo class Logo
@ -68,7 +68,7 @@ private:
void extrude(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); void extrude(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
void add(const QVector3D &v, const QVector3D &n); void add(const QVector3D &v, const QVector3D &n);
QVector<GLfloat> m_data; QList<GLfloat> m_data;
int m_count = 0; int m_count = 0;
}; };

View File

@ -83,8 +83,8 @@ private:
void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4); void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
void extrude(qreal x1, qreal y1, qreal x2, qreal y2); void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
QVector<QVector3D> vertices; QList<QVector3D> vertices;
QVector<QVector3D> normals; QList<QVector3D> normals;
int vertexAttr; int vertexAttr;
int normalAttr; int normalAttr;
int matrixUniform; int matrixUniform;

View File

@ -319,7 +319,7 @@ void GLWidget::initializeGL()
// let's do something different and potentially more efficient: create a // let's do something different and potentially more efficient: create a
// properly interleaved data set. // properly interleaved data set.
const int vertexCount = m_vertices.count(); const int vertexCount = m_vertices.count();
QVector<GLfloat> buf; QList<GLfloat> buf;
buf.resize(vertexCount * 3 * 2); buf.resize(vertexCount * 3 * 2);
GLfloat *p = buf.data(); GLfloat *p = buf.data();
for (int i = 0; i < vertexCount; ++i) { for (int i = 0; i < vertexCount; ++i) {

View File

@ -57,7 +57,7 @@
#include <QVector3D> #include <QVector3D>
#include <QMatrix4x4> #include <QMatrix4x4>
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QVector> #include <QList>
#include <QPushButton> #include <QPushButton>
class Bubble; class Bubble;
@ -101,10 +101,10 @@ private:
qreal m_fAngle = 0; qreal m_fAngle = 0;
qreal m_fScale = 1; qreal m_fScale = 1;
bool m_showBubbles = true; bool m_showBubbles = true;
QVector<QVector3D> m_vertices; QList<QVector3D> m_vertices;
QVector<QVector3D> m_normals; QList<QVector3D> m_normals;
bool m_qtLogo = true; bool m_qtLogo = true;
QVector<Bubble *> m_bubbles; QList<Bubble *> m_bubbles;
int m_frames = 0; int m_frames = 0;
QElapsedTimer m_time; QElapsedTimer m_time;
QOpenGLShader *m_vshader1 = nullptr; QOpenGLShader *m_vshader1 = nullptr;

View File

@ -77,7 +77,7 @@ private:
QGridLayout *m_layout; QGridLayout *m_layout;
int m_nextX; int m_nextX;
int m_nextY; int m_nextY;
QVector<QOpenGLWidget *> m_glWidgets; QList<QOpenGLWidget *> m_glWidgets;
}; };
#endif #endif

View File

@ -199,7 +199,7 @@ void GLWidget::makeObject()
for (int j = 0; j < 6; ++j) for (int j = 0; j < 6; ++j)
textures[j] = new QOpenGLTexture(QImage(QString(":/images/side%1.png").arg(j + 1)).mirrored()); textures[j] = new QOpenGLTexture(QImage(QString(":/images/side%1.png").arg(j + 1)).mirrored());
QVector<GLfloat> vertData; QList<GLfloat> vertData;
for (int i = 0; i < 6; ++i) { for (int i = 0; i < 6; ++i) {
for (int j = 0; j < 4; ++j) { for (int j = 0; j < 4; ++j) {
// vertex position // vertex position

View File

@ -91,8 +91,8 @@ private:
bool m_inited = false; bool m_inited = false;
qreal m_fAngle = 0; qreal m_fAngle = 0;
qreal m_fScale = 1; qreal m_fScale = 1;
QVector<QVector3D> vertices; QList<QVector3D> vertices;
QVector<QVector3D> normals; QList<QVector3D> normals;
QOpenGLShaderProgram program; QOpenGLShaderProgram program;
QOpenGLBuffer vbo; QOpenGLBuffer vbo;
int vertexAttr = 0; int vertexAttr = 0;

View File

@ -61,10 +61,10 @@ int main(int argc, char **argv)
const int iterations = 20; const int iterations = 20;
// Prepare the vector. // Prepare the list.
QVector<int> vector; QList<int> list;
for (int i = 0; i < iterations; ++i) for (int i = 0; i < iterations; ++i)
vector.append(i); list.append(i);
// Create a progress dialog. // Create a progress dialog.
QProgressDialog dialog; QProgressDialog dialog;
@ -88,7 +88,7 @@ int main(int argc, char **argv)
}; };
// Start the computation. // Start the computation.
futureWatcher.setFuture(QtConcurrent::map(vector, spin)); futureWatcher.setFuture(QtConcurrent::map(list, spin));
// Display the dialog and start the event loop. // Display the dialog and start the event loop.
dialog.exec(); dialog.exec();

View File

@ -96,7 +96,7 @@ Renderer::Renderer(VulkanWindow *w, int initialCount)
void Renderer::preInitResources() void Renderer::preInitResources()
{ {
const QVector<int> sampleCounts = m_window->supportedSampleCounts(); const QList<int> sampleCounts = m_window->supportedSampleCounts();
if (DBG) if (DBG)
qDebug() << "Supported sample counts:" << sampleCounts; qDebug() << "Supported sample counts:" << sampleCounts;
if (sampleCounts.contains(4)) { if (sampleCounts.contains(4)) {

View File

@ -82,7 +82,7 @@ int main(int argc, char *argv[])
VulkanWindow w; VulkanWindow w;
w.setVulkanInstance(&inst); w.setVulkanInstance(&inst);
if (QCoreApplication::arguments().contains(QStringLiteral("--srgb"))) if (QCoreApplication::arguments().contains(QStringLiteral("--srgb")))
w.setPreferredColorFormats(QVector<VkFormat>() << VK_FORMAT_B8G8R8A8_SRGB); w.setPreferredColorFormats(QList<VkFormat>() << VK_FORMAT_B8G8R8A8_SRGB);
w.resize(1024, 768); w.resize(1024, 768);
w.show(); w.show();

View File

@ -170,7 +170,7 @@ void VulkanRenderer::initResources()
m_window->colorFormat(), m_window->depthStencilFormat()); m_window->colorFormat(), m_window->depthStencilFormat());
info += QStringLiteral("Supported sample counts:"); info += QStringLiteral("Supported sample counts:");
const QVector<int> sampleCounts = m_window->supportedSampleCounts(); const QList<int> sampleCounts = m_window->supportedSampleCounts();
for (int count : sampleCounts) for (int count : sampleCounts)
info += QLatin1Char(' ') + QString::number(count); info += QLatin1Char(' ') + QString::number(count);
info += QLatin1Char('\n'); info += QLatin1Char('\n');

View File

@ -73,7 +73,7 @@ TriangleRenderer::TriangleRenderer(QVulkanWindow *w, bool msaa)
: m_window(w) : m_window(w)
{ {
if (msaa) { if (msaa) {
const QVector<int> counts = w->supportedSampleCounts(); const QList<int> counts = w->supportedSampleCounts();
qDebug() << "Supported sample counts:" << counts; qDebug() << "Supported sample counts:" << counts;
for (int s = 16; s >= 4; s /= 2) { for (int s = 16; s >= 4; s /= 2) {
if (counts.contains(s)) { if (counts.contains(s)) {

View File

@ -79,7 +79,7 @@ public:
} }
private: private:
QVector<QPointF> m_nodePositions; QList<QPointF> m_nodePositions;
}; };
Animation::Animation() : m_currentFrame(0) Animation::Animation() : m_currentFrame(0)

View File

@ -53,7 +53,7 @@
#include <QPointF> #include <QPointF>
#include <QString> #include <QString>
#include <QVector> #include <QList>
class Frame; class Frame;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -85,7 +85,7 @@ public:
private: private:
QString m_name; QString m_name;
QVector<Frame *> m_frames; QList<Frame *> m_frames;
int m_currentFrame; int m_currentFrame;
}; };

View File

@ -76,7 +76,7 @@ private slots:
void unregisterAnimation_helper(QObject *obj); void unregisterAnimation_helper(QObject *obj);
private: private:
QVector<QAbstractAnimation *> animations; QList<QAbstractAnimation *> animations;
}; };
#endif // ANIMATIONMANAGER_H #endif // ANIMATIONMANAGER_H

View File

@ -85,7 +85,7 @@ public:
struct LevelDescription { struct LevelDescription {
int id = 0; int id = 0;
QString name; QString name;
QVector<QPair<int, int>> submarines; QList<QPair<int, int>> submarines;
}; };
GraphicsScene(int x, int y, int width, int height, Mode mode, QObject *parent = nullptr); GraphicsScene(int x, int y, int width, int height, Mode mode, QObject *parent = nullptr);
@ -114,7 +114,7 @@ private:
QSet<SubMarine *> submarines; QSet<SubMarine *> submarines;
QSet<Bomb *> bombs; QSet<Bomb *> bombs;
QSet<Torpedo *> torpedos; QSet<Torpedo *> torpedos;
QVector<SubmarineDescription> submarinesData; QList<SubmarineDescription> submarinesData;
QHash<int, LevelDescription> levelsData; QHash<int, LevelDescription> levelsData;
friend class PauseState; friend class PauseState;

View File

@ -90,8 +90,8 @@
\snippet itemviews/addressbook/tablemodel.h 0 \snippet itemviews/addressbook/tablemodel.h 0
Two constructors are used, a default constructor which uses Two constructors are used, a default constructor which uses
\c TableModel's own \c {QVector<Contact>} and one that takes \c TableModel's own \c {QList<Contact>} and one that takes
\c {QVector<Contact>} as an argument, for convenience. \c {QList<Contact>} as an argument, for convenience.
\section1 TableModel Class Implementation \section1 TableModel Class Implementation
@ -161,7 +161,7 @@
them here so that we can reuse the model in other programs. them here so that we can reuse the model in other programs.
The last function in \c {TableModel}, \c getContacts() returns the The last function in \c {TableModel}, \c getContacts() returns the
QVector<Contact> object that holds all the contacts in the address QList<Contact> object that holds all the contacts in the address
book. We use this function later to obtain the list of contacts to book. We use this function later to obtain the list of contacts to
check for existing entries, write the contacts to a file and read check for existing entries, write the contacts to a file and read
them back. Further explanation is given with \c AddressWidget. them back. Further explanation is given with \c AddressWidget.

View File

@ -128,7 +128,7 @@
Each cell in the table will be padded and spaced to make the text easier to Each cell in the table will be padded and spaced to make the text easier to
read. read.
We want the columns to have equal widths, so we provide a vector containing We want the columns to have equal widths, so we provide a list containing
percentage widths for each of them and set the constraints in the percentage widths for each of them and set the constraints in the
QTextTableFormat: QTextTableFormat:

View File

@ -260,7 +260,7 @@
QIcon::Active, QIcon::Disabled, QIcon::Selected and the rows in the order QIcon::Active, QIcon::Disabled, QIcon::Selected and the rows in the order
QIcon::Off, QIcon::On, which does not match the enumeration. The above code QIcon::Off, QIcon::On, which does not match the enumeration. The above code
provides arrays allowing to map from enumeration value to row/column provides arrays allowing to map from enumeration value to row/column
(by using QVector::indexOf()) and back by using the array index and lists (by using QList::indexOf()) and back by using the array index and lists
of the matching strings. Qt's containers can be easily populated by of the matching strings. Qt's containers can be easily populated by
using C++ 11 initializer lists. using C++ 11 initializer lists.

View File

@ -66,7 +66,7 @@
We have chosen to store our highlighting rules using a private We have chosen to store our highlighting rules using a private
struct: A rule consists of a QRegularExpression pattern and a struct: A rule consists of a QRegularExpression pattern and a
QTextCharFormat instance. The various rules are then stored using a QTextCharFormat instance. The various rules are then stored using a
QVector. QList.
The QTextCharFormat class provides formatting information for The QTextCharFormat class provides formatting information for
characters in a QTextDocument specifying the visual properties of characters in a QTextDocument specifying the visual properties of
@ -137,7 +137,7 @@
blocks that have changed. blocks that have changed.
First we apply the syntax highlighting rules that we stored in the First we apply the syntax highlighting rules that we stored in the
\c highlightingRules vector. For each rule (i.e. for each \c highlightingRules list. For each rule (i.e. for each
HighlightingRule object) we search for the pattern in the given HighlightingRule object) we search for the pattern in the given
text block using the QString::indexOf() function. When the first text block using the QString::indexOf() function. When the first
occurrence of the pattern is found, we use the occurrence of the pattern is found, we use the

View File

@ -95,7 +95,7 @@
\snippet widgets/tooltips/sortingbox.h 2 \snippet widgets/tooltips/sortingbox.h 2
We keep all the shape items in a QVector, and we keep three We keep all the shape items in a QList, and we keep three
QPainterPath objects holding the shapes of a circle, a square and QPainterPath objects holding the shapes of a circle, a square and
a triangle. We also need to have a pointer to an item when it is a triangle. We also need to have a pointer to an item when it is
moving, and we need to know its previous position. moving, and we need to know its previous position.

View File

@ -53,7 +53,7 @@
#include <QPoint> #include <QPoint>
#include <QPixmap> #include <QPixmap>
#include <QVector> #include <QList>
#include <QWidget> #include <QWidget>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -94,7 +94,7 @@ private:
int findPiece(const QRect &pieceRect) const; int findPiece(const QRect &pieceRect) const;
const QRect targetSquare(const QPoint &position) const; const QRect targetSquare(const QPoint &position) const;
QVector<Piece> pieces; QList<Piece> pieces;
QRect highlightedRect; QRect highlightedRect;
int inPlace; int inPlace;
int m_ImageSize; int m_ImageSize;

View File

@ -66,7 +66,7 @@ ImageWidget::ImageWidget(QWidget *parent)
} }
//! [constructor] //! [constructor]
void ImageWidget::grabGestures(const QVector<Qt::GestureType> &gestures) void ImageWidget::grabGestures(const QList<Qt::GestureType> &gestures)
{ {
//! [enable gestures] //! [enable gestures]
for (Qt::GestureType gesture : gestures) for (Qt::GestureType gesture : gestures)

View File

@ -72,7 +72,7 @@ class ImageWidget : public QWidget
public: public:
ImageWidget(QWidget *parent = nullptr); ImageWidget(QWidget *parent = nullptr);
void openDirectory(const QString &path); void openDirectory(const QString &path);
void grabGestures(const QVector<Qt::GestureType> &gestures); void grabGestures(const QList<Qt::GestureType> &gestures);
protected: protected:
bool event(QEvent *event) override; bool event(QEvent *event) override;

View File

@ -102,7 +102,7 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
QVector<Qt::GestureType> gestures; QList<Qt::GestureType> gestures;
if (!commandLineParser.isSet(disablePanOption)) if (!commandLineParser.isSet(disablePanOption))
gestures << Qt::PanGesture; gestures << Qt::PanGesture;
if (!commandLineParser.isSet(disablePinchOption)) if (!commandLineParser.isSet(disablePinchOption))

View File

@ -72,7 +72,7 @@ void MainWidget::openDirectory(const QString &path)
imageWidget->openDirectory(path); imageWidget->openDirectory(path);
} }
void MainWidget::grabGestures(const QVector<Qt::GestureType> &gestures) void MainWidget::grabGestures(const QList<Qt::GestureType> &gestures)
{ {
imageWidget->grabGestures(gestures); imageWidget->grabGestures(gestures);
} }

View File

@ -61,7 +61,7 @@ class MainWidget : public QMainWindow
public: public:
MainWidget(QWidget *parent = nullptr); MainWidget(QWidget *parent = nullptr);
void grabGestures(const QVector<Qt::GestureType> &gestures); void grabGestures(const QList<Qt::GestureType> &gestures);
public slots: public slots:
void openDirectory(const QString &path); void openDirectory(const QString &path);

View File

@ -72,7 +72,7 @@ private:
int x; int x;
int y; int y;
QColor color; QColor color;
QVector<QPointF> stuff; QList<QPointF> stuff;
}; };
#endif // CHIP_H #endif // CHIP_H

View File

@ -52,7 +52,7 @@
#define DIAGRAMITEM_H #define DIAGRAMITEM_H
#include <QGraphicsPixmapItem> #include <QGraphicsPixmapItem>
#include <QVector> #include <QList>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QPixmap; class QPixmap;
@ -88,7 +88,7 @@ private:
DiagramType myDiagramType; DiagramType myDiagramType;
QPolygonF myPolygon; QPolygonF myPolygon;
QMenu *myContextMenu; QMenu *myContextMenu;
QVector<Arrow *> arrows; QList<Arrow *> arrows;
}; };
//! [0] //! [0]

View File

@ -163,7 +163,7 @@ void GraphWidget::timerEvent(QTimerEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
QVector<Node *> nodes; QList<Node *> nodes;
const QList<QGraphicsItem *> items = scene()->items(); const QList<QGraphicsItem *> items = scene()->items();
for (QGraphicsItem *item : items) { for (QGraphicsItem *item : items) {
if (Node *node = qgraphicsitem_cast<Node *>(item)) if (Node *node = qgraphicsitem_cast<Node *>(item))

View File

@ -75,7 +75,7 @@ void Node::addEdge(Edge *edge)
edge->adjust(); edge->adjust();
} }
QVector<Edge *> Node::edges() const QList<Edge *> Node::edges() const
{ {
return edgeList; return edgeList;
} }

View File

@ -52,7 +52,7 @@
#define NODE_H #define NODE_H
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QVector> #include <QList>
class Edge; class Edge;
class GraphWidget; class GraphWidget;
@ -64,7 +64,7 @@ public:
Node(GraphWidget *graphWidget); Node(GraphWidget *graphWidget);
void addEdge(Edge *edge); void addEdge(Edge *edge);
QVector<Edge *> edges() const; QList<Edge *> edges() const;
enum { Type = UserType + 1 }; enum { Type = UserType + 1 };
int type() const override { return Type; } int type() const override { return Type; }
@ -83,7 +83,7 @@ protected:
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
private: private:
QVector<Edge *> edgeList; QList<Edge *> edgeList;
QPointF newPos; QPointF newPos;
GraphWidget *graph; GraphWidget *graph;
}; };

View File

@ -75,7 +75,7 @@ private:
QSizeF prefSize() const; QSizeF prefSize() const;
QSizeF maxSize() const; QSizeF maxSize() const;
QVector<QGraphicsLayoutItem*> m_items; QList<QGraphicsLayoutItem *> m_items;
qreal m_spacing[2] = {6, 6}; qreal m_spacing[2] = {6, 6};
}; };

View File

@ -59,7 +59,7 @@ Window::Window(QGraphicsItem *parent) : QGraphicsWidget(parent, Qt::Window)
FlowLayout *lay = new FlowLayout; FlowLayout *lay = new FlowLayout;
const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown." const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown."
" I am bothered when I do not know others. (Confucius)")); " I am bothered when I do not know others. (Confucius)"));
const QVector<QStringRef> words = sentence.splitRef(QLatin1Char(' '), Qt::SkipEmptyParts); const QList<QStringRef> words = sentence.splitRef(QLatin1Char(' '), Qt::SkipEmptyParts);
for (const QStringRef &word : words) { for (const QStringRef &word : words) {
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
QLabel *label = new QLabel(word.toString()); QLabel *label = new QLabel(word.toString());

View File

@ -75,7 +75,7 @@ FlippablePad::FlippablePad(const QSize &size, QGraphicsItem *parent)
//! [2] //! [2]
//! [3] //! [3]
int numIcons = size.width() * size.height(); int numIcons = size.width() * size.height();
QVector<QPixmap> pixmaps; QList<QPixmap> pixmaps;
QDirIterator it(":/images", {"*.png"}); QDirIterator it(":/images", {"*.png"});
while (it.hasNext() && pixmaps.size() < numIcons) while (it.hasNext() && pixmaps.size() < numIcons)
pixmaps << it.next(); pixmaps << it.next();

View File

@ -53,7 +53,7 @@
#include "roundrectitem.h" #include "roundrectitem.h"
#include <QVector> #include <QList>
//! [0] //! [0]
class FlippablePad : public RoundRectItem class FlippablePad : public RoundRectItem
@ -64,7 +64,7 @@ public:
RoundRectItem *iconAt(int column, int row) const; RoundRectItem *iconAt(int column, int row) const;
private: private:
QVector<QVector<RoundRectItem *> > iconGrid; QList<QList<RoundRectItem *>> iconGrid;
}; };
//! [0] //! [0]

View File

@ -228,7 +228,7 @@ PadNavigator::PadNavigator(const QSize &size, QWidget *parent)
// Create substates for each icon; store in temporary grid. // Create substates for each icon; store in temporary grid.
int columns = size.width(); int columns = size.width();
int rows = size.height(); int rows = size.height();
QVector< QVector< QState * > > stateGrid; QList<QList<QState *>> stateGrid;
stateGrid.resize(rows); stateGrid.resize(rows);
for (int y = 0; y < rows; ++y) { for (int y = 0; y < rows; ++y) {
stateGrid[y].resize(columns); stateGrid[y].resize(columns);

View File

@ -201,7 +201,7 @@ void AddressWidget::readFromFile(const QString &fileName)
return; return;
} }
QVector<Contact> contacts; QList<Contact> contacts;
QDataStream in(&file); QDataStream in(&file);
in >> contacts; in >> contacts;

View File

@ -56,9 +56,8 @@ TableModel::TableModel(QObject *parent)
{ {
} }
TableModel::TableModel(const QVector<Contact> &contacts, QObject *parent) TableModel::TableModel(const QList<Contact> &contacts, QObject *parent)
: QAbstractTableModel(parent), : QAbstractTableModel(parent), contacts(contacts)
contacts(contacts)
{ {
} }
//! [0] //! [0]
@ -186,7 +185,7 @@ Qt::ItemFlags TableModel::flags(const QModelIndex &index) const
//! [7] //! [7]
//! [8] //! [8]
const QVector<Contact> &TableModel::getContacts() const const QList<Contact> &TableModel::getContacts() const
{ {
return contacts; return contacts;
} }

View File

@ -52,7 +52,7 @@
#define TABLEMODEL_H #define TABLEMODEL_H
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QVector> #include <QList>
//! [0] //! [0]
@ -83,7 +83,7 @@ class TableModel : public QAbstractTableModel
public: public:
TableModel(QObject *parent = nullptr); TableModel(QObject *parent = nullptr);
TableModel(const QVector<Contact> &contacts, QObject *parent = nullptr); TableModel(const QList<Contact> &contacts, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override; int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override; int columnCount(const QModelIndex &parent) const override;
@ -93,10 +93,10 @@ public:
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex()) override; bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;
bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex()) override; bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;
const QVector<Contact> &getContacts() const; const QList<Contact> &getContacts() const;
private: private:
QVector<Contact> contacts; QList<Contact> contacts;
}; };
//! [0] //! [0]

View File

@ -59,9 +59,8 @@ PieView::PieView(QWidget *parent)
verticalScrollBar()->setRange(0, 0); verticalScrollBar()->setRange(0, 0);
} }
void PieView::dataChanged(const QModelIndex &topLeft, void PieView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
const QModelIndex &bottomRight, const QList<int> &roles)
const QVector<int> &roles)
{ {
QAbstractItemView::dataChanged(topLeft, bottomRight, roles); QAbstractItemView::dataChanged(topLeft, bottomRight, roles);

View File

@ -67,7 +67,7 @@ public:
protected slots: protected slots:
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
const QVector<int> &roles = QVector<int>()) override; const QList<int> &roles = QList<int>()) override;
void rowsInserted(const QModelIndex &parent, int start, int end) override; void rowsInserted(const QModelIndex &parent, int start, int end) override;
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override; void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;

View File

@ -71,8 +71,7 @@ Window::Window()
void Window::createGUI() void Window::createGUI()
{ {
const QVector<QPair<QString, QColor> > list = const QList<QPair<QString, QColor>> list = { { tr("Alice"), QColor("aliceblue") },
{{ tr("Alice"), QColor("aliceblue") },
{ tr("Neptun"), QColor("aquamarine") }, { tr("Neptun"), QColor("aquamarine") },
{ tr("Ferdinand"), QColor("springgreen") } }; { tr("Ferdinand"), QColor("springgreen") } };

View File

@ -57,9 +57,8 @@
#include "treeitem.h" #include "treeitem.h"
//! [0] //! [0]
TreeItem::TreeItem(const QVector<QVariant> &data, TreeItem *parent) TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
: itemData(data), : itemData(data), parentItem(parent)
parentItem(parent)
{} {}
//! [0] //! [0]
@ -118,7 +117,7 @@ bool TreeItem::insertChildren(int position, int count, int columns)
return false; return false;
for (int row = 0; row < count; ++row) { for (int row = 0; row < count; ++row) {
QVector<QVariant> data(columns); QList<QVariant> data(columns);
TreeItem *item = new TreeItem(data, this); TreeItem *item = new TreeItem(data, this);
childItems.insert(position, item); childItems.insert(position, item);
} }

View File

@ -52,13 +52,13 @@
#define TREEITEM_H #define TREEITEM_H
#include <QVariant> #include <QVariant>
#include <QVector> #include <QList>
//! [0] //! [0]
class TreeItem class TreeItem
{ {
public: public:
explicit TreeItem(const QVector<QVariant> &data, TreeItem *parent = nullptr); explicit TreeItem(const QList<QVariant> &data, TreeItem *parent = nullptr);
~TreeItem(); ~TreeItem();
TreeItem *child(int number); TreeItem *child(int number);
@ -74,8 +74,8 @@ public:
bool setData(int column, const QVariant &value); bool setData(int column, const QVariant &value);
private: private:
QVector<TreeItem*> childItems; QList<TreeItem *> childItems;
QVector<QVariant> itemData; QList<QVariant> itemData;
TreeItem *parentItem; TreeItem *parentItem;
}; };
//! [0] //! [0]

View File

@ -57,7 +57,7 @@
TreeModel::TreeModel(const QStringList &headers, const QString &data, QObject *parent) TreeModel::TreeModel(const QStringList &headers, const QString &data, QObject *parent)
: QAbstractItemModel(parent) : QAbstractItemModel(parent)
{ {
QVector<QVariant> rootData; QList<QVariant> rootData;
for (const QString &header : headers) for (const QString &header : headers)
rootData << header; rootData << header;
@ -248,8 +248,8 @@ bool TreeModel::setHeaderData(int section, Qt::Orientation orientation,
void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent) void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
{ {
QVector<TreeItem*> parents; QList<TreeItem *> parents;
QVector<int> indentations; QList<int> indentations;
parents << parent; parents << parent;
indentations << 0; indentations << 0;
@ -269,7 +269,7 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
// Read the column data from the rest of the line. // Read the column data from the rest of the line.
const QStringList columnStrings = const QStringList columnStrings =
lineData.split(QLatin1Char('\t'), Qt::SkipEmptyParts); lineData.split(QLatin1Char('\t'), Qt::SkipEmptyParts);
QVector<QVariant> columnData; QList<QVariant> columnData;
columnData.reserve(columnStrings.size()); columnData.reserve(columnStrings.size());
for (const QString &columnString : columnStrings) for (const QString &columnString : columnStrings)
columnData << columnString; columnData << columnString;

View File

@ -55,8 +55,9 @@
Model::Model(int rows, int columns, QObject *parent) Model::Model(int rows, int columns, QObject *parent)
: QAbstractItemModel(parent), : QAbstractItemModel(parent),
services(QPixmap(":/images/services.png")), services(QPixmap(":/images/services.png")),
rc(rows), cc(columns), rc(rows),
tree(new QVector<Node>(rows, Node())) cc(columns),
tree(new QList<Node>(rows, Node()))
{ {
} }
@ -139,8 +140,8 @@ Qt::ItemFlags Model::flags(const QModelIndex &index) const
Model::Node *Model::node(int row, Node *parent) const Model::Node *Model::node(int row, Node *parent) const
{ {
if (parent && !parent->children) if (parent && !parent->children)
parent->children = new QVector<Node>(rc, Node(parent)); parent->children = new QList<Node>(rc, Node(parent));
QVector<Node> *v = parent ? parent->children : tree; QList<Node> *v = parent ? parent->children : tree;
return const_cast<Node*>(&(v->at(row))); return const_cast<Node*>(&(v->at(row)));
} }

View File

@ -54,7 +54,7 @@
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QFileIconProvider> #include <QFileIconProvider>
#include <QIcon> #include <QIcon>
#include <QVector> #include <QList>
class Model : public QAbstractItemModel class Model : public QAbstractItemModel
{ {
@ -83,7 +83,7 @@ private:
Node(Node *parent = nullptr) : parent(parent), children(nullptr) {} Node(Node *parent = nullptr) : parent(parent), children(nullptr) {}
~Node() { delete children; } ~Node() { delete children; }
Node *parent; Node *parent;
QVector<Node> *children; QList<Node> *children;
}; };
Node *node(int row, Node *parent) const; Node *node(int row, Node *parent) const;
@ -93,7 +93,7 @@ private:
QIcon services; QIcon services;
int rc; int rc;
int cc; int cc;
QVector<Node> *tree; QList<Node> *tree;
QFileIconProvider iconProvider; QFileIconProvider iconProvider;
}; };

View File

@ -55,7 +55,7 @@
#include <QPixmap> #include <QPixmap>
#include <QPoint> #include <QPoint>
#include <QStringList> #include <QStringList>
#include <QVector> #include <QList>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QMimeData; class QMimeData;
@ -83,8 +83,8 @@ public:
void addPieces(const QPixmap &pixmap); void addPieces(const QPixmap &pixmap);
private: private:
QVector<QPoint> locations; QList<QPoint> locations;
QVector<QPixmap> pixmaps; QList<QPixmap> pixmaps;
int m_PieceSize; int m_PieceSize;
}; };

View File

@ -53,7 +53,7 @@
#include <QPoint> #include <QPoint>
#include <QPixmap> #include <QPixmap>
#include <QVector> #include <QList>
#include <QWidget> #include <QWidget>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -94,7 +94,7 @@ private:
int findPiece(const QRect &pieceRect) const; int findPiece(const QRect &pieceRect) const;
const QRect targetSquare(const QPoint &position) const; const QRect targetSquare(const QPoint &position) const;
QVector<Piece> pieces; QList<Piece> pieces;
QRect highlightedRect; QRect highlightedRect;
int inPlace; int inPlace;
int m_ImageSize; int m_ImageSize;

View File

@ -57,7 +57,7 @@
#include "treeitem.h" #include "treeitem.h"
//! [0] //! [0]
TreeItem::TreeItem(const QVector<QVariant> &data, TreeItem *parent) TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
: m_itemData(data), m_parentItem(parent) : m_itemData(data), m_parentItem(parent)
{} {}
//! [0] //! [0]

View File

@ -52,13 +52,13 @@
#define TREEITEM_H #define TREEITEM_H
#include <QVariant> #include <QVariant>
#include <QVector> #include <QList>
//! [0] //! [0]
class TreeItem class TreeItem
{ {
public: public:
explicit TreeItem(const QVector<QVariant> &data, TreeItem *parentItem = nullptr); explicit TreeItem(const QList<QVariant> &data, TreeItem *parentItem = nullptr);
~TreeItem(); ~TreeItem();
void appendChild(TreeItem *child); void appendChild(TreeItem *child);
@ -71,8 +71,8 @@ public:
TreeItem *parentItem(); TreeItem *parentItem();
private: private:
QVector<TreeItem*> m_childItems; QList<TreeItem *> m_childItems;
QVector<QVariant> m_itemData; QList<QVariant> m_itemData;
TreeItem *m_parentItem; TreeItem *m_parentItem;
}; };
//! [0] //! [0]

View File

@ -175,8 +175,8 @@ int TreeModel::rowCount(const QModelIndex &parent) const
void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent) void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
{ {
QVector<TreeItem*> parents; QList<TreeItem *> parents;
QVector<int> indentations; QList<int> indentations;
parents << parent; parents << parent;
indentations << 0; indentations << 0;
@ -196,7 +196,7 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
// Read the column data from the rest of the line. // Read the column data from the rest of the line.
const QStringList columnStrings = const QStringList columnStrings =
lineData.split(QLatin1Char('\t'), Qt::SkipEmptyParts); lineData.split(QLatin1Char('\t'), Qt::SkipEmptyParts);
QVector<QVariant> columnData; QList<QVariant> columnData;
columnData.reserve(columnStrings.count()); columnData.reserve(columnStrings.count());
for (const QString &columnString : columnStrings) for (const QString &columnString : columnStrings)
columnData << columnString; columnData << columnString;

View File

@ -105,8 +105,8 @@ private:
// int m_fpsCounter; // int m_fpsCounter;
QElapsedTimer m_repaintTracker; QElapsedTimer m_repaintTracker;
QVector<QPainterPath> m_paths; QList<QPainterPath> m_paths;
QVector<QPointF> m_advances; QList<QPointF> m_advances;
QRectF m_pathBounds; QRectF m_pathBounds;
QString m_text; QString m_text;

View File

@ -542,7 +542,7 @@ GradientRenderer::GradientRenderer(QWidget *parent)
m_hoverPoints->setConnectionType(HoverPoints::NoConnection); m_hoverPoints->setConnectionType(HoverPoints::NoConnection);
m_hoverPoints->setEditable(false); m_hoverPoints->setEditable(false);
QVector<QPointF> points; QList<QPointF> points;
points << QPointF(100, 100) << QPointF(200, 200); points << QPointF(100, 100) << QPointF(200, 200);
m_hoverPoints->setPoints(points); m_hoverPoints->setPoints(points);

View File

@ -470,7 +470,7 @@ void PathStrokeRenderer::paint(QPainter *painter)
stroker.setJoinStyle(m_joinStyle); stroker.setJoinStyle(m_joinStyle);
stroker.setCapStyle(m_capStyle); stroker.setCapStyle(m_capStyle);
QVector<qreal> dashes; QList<qreal> dashes;
qreal space = 4; qreal space = 4;
dashes << 1 << space dashes << 1 << space
<< 3 << space << 3 << space

View File

@ -119,8 +119,8 @@ private:
int m_pointCount; int m_pointCount;
int m_pointSize; int m_pointSize;
int m_activePoint; int m_activePoint;
QVector<QPointF> m_points; QList<QPointF> m_points;
QVector<QPointF> m_vectors; QList<QPointF> m_vectors;
Qt::PenJoinStyle m_joinStyle; Qt::PenJoinStyle m_joinStyle;
Qt::PenCapStyle m_capStyle; Qt::PenCapStyle m_capStyle;

View File

@ -135,7 +135,7 @@ private:
SortType m_sortType; SortType m_sortType;
ConnectionType m_connectionType; ConnectionType m_connectionType;
QVector<uint> m_locks; QList<uint> m_locks;
QSizeF m_pointSize; QSizeF m_pointSize;
int m_currentIndex; int m_currentIndex;

View File

@ -132,7 +132,7 @@ void MainWindow::insertCalendar()
tableFormat.setCellPadding(2); tableFormat.setCellPadding(2);
tableFormat.setCellSpacing(4); tableFormat.setCellSpacing(4);
//! [6] //! [7] //! [6] //! [7]
QVector<QTextLength> constraints; QList<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 14) constraints << QTextLength(QTextLength::PercentageLength, 14)
<< QTextLength(QTextLength::PercentageLength, 14) << QTextLength(QTextLength::PercentageLength, 14)
<< QTextLength(QTextLength::PercentageLength, 14) << QTextLength(QTextLength::PercentageLength, 14)

View File

@ -76,7 +76,7 @@ private:
QRegularExpression pattern; QRegularExpression pattern;
QTextCharFormat format; QTextCharFormat format;
}; };
QVector<HighlightingRule> highlightingRules; QList<HighlightingRule> highlightingRules;
QRegularExpression commentStartExpression; QRegularExpression commentStartExpression;
QRegularExpression commentEndExpression; QRegularExpression commentEndExpression;

View File

@ -201,7 +201,7 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString &fileName)
#endif #endif
QStandardItemModel *model = new QStandardItemModel(completer); QStandardItemModel *model = new QStandardItemModel(completer);
QVector<QStandardItem *> parents(10); QList<QStandardItem *> parents(10);
parents[0] = model->invisibleRootItem(); parents[0] = model->invisibleRootItem();
QRegularExpression re("^\\s+"); QRegularExpression re("^\\s+");

View File

@ -121,7 +121,7 @@ private:
int indexAt(const QPoint &pos) const; int indexAt(const QPoint &pos) const;
QString uniqueName(const QString &name) const; QString uniqueName(const QString &name) const;
QVector<Shape> m_shapeList; QList<Shape> m_shapeList;
QPoint m_mousePressOffset; QPoint m_mousePressOffset;
QString m_fileName; QString m_fileName;
QUndoStack *m_undoStack = nullptr; QUndoStack *m_undoStack = nullptr;

View File

@ -81,15 +81,16 @@ IconPreviewArea::IconPreviewArea(QWidget *parent)
//! [0] //! [0]
//! [42] //! [42]
QVector<QIcon::Mode> IconPreviewArea::iconModes() QList<QIcon::Mode> IconPreviewArea::iconModes()
{ {
static const QVector<QIcon::Mode> result = {QIcon::Normal, QIcon::Active, QIcon::Disabled, QIcon::Selected}; static const QList<QIcon::Mode> result = { QIcon::Normal, QIcon::Active, QIcon::Disabled,
QIcon::Selected };
return result; return result;
} }
QVector<QIcon::State> IconPreviewArea::iconStates() QList<QIcon::State> IconPreviewArea::iconStates()
{ {
static const QVector<QIcon::State> result = {QIcon::Off, QIcon::On}; static const QList<QIcon::State> result = { QIcon::Off, QIcon::On };
return result; return result;
} }

View File

@ -54,7 +54,7 @@
#include <QIcon> #include <QIcon>
#include <QWidget> #include <QWidget>
#include <QStringList> #include <QStringList>
#include <QVector> #include <QList>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QLabel; class QLabel;
@ -71,8 +71,8 @@ public:
void setIcon(const QIcon &icon); void setIcon(const QIcon &icon);
void setSize(const QSize &size); void setSize(const QSize &size);
static QVector<QIcon::Mode> iconModes(); static QList<QIcon::Mode> iconModes();
static QVector<QIcon::State> iconStates(); static QList<QIcon::State> iconStates();
static QStringList iconModeNames(); static QStringList iconModeNames();
static QStringList iconStateNames(); static QStringList iconStateNames();

View File

@ -99,7 +99,7 @@ private:
const char *member); const char *member);
//! [2] //! [2]
QVector<ShapeItem> shapeItems; QList<ShapeItem> shapeItems;
QPainterPath circlePath; QPainterPath circlePath;
QPainterPath squarePath; QPainterPath squarePath;
QPainterPath trianglePath; QPainterPath trianglePath;