Cleanup Widgets examples - nullptr
Cleanup the widgets examples - replace 0 with nullptr Change-Id: Id4bf119b9a41f6d10117f3a613a6e604128fa196 Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
This commit is contained in:
parent
c590aa678d
commit
aa32510430
@ -69,7 +69,7 @@ class Button : public QGraphicsWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Button(const QPixmap &pixmap, QGraphicsItem *parent = 0)
|
Button(const QPixmap &pixmap, QGraphicsItem *parent = nullptr)
|
||||||
: QGraphicsWidget(parent), _pix(pixmap)
|
: QGraphicsWidget(parent), _pix(pixmap)
|
||||||
{
|
{
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
class Window : public QWidget {
|
class Window : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Window(QWidget *parent = 0);
|
Window(QWidget *parent = nullptr);
|
||||||
private slots:
|
private slots:
|
||||||
void curveChanged(int row);
|
void curveChanged(int row);
|
||||||
void pathChanged(int index);
|
void pathChanged(int index);
|
||||||
|
@ -169,7 +169,8 @@ class GraphicsView : public QGraphicsView
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GraphicsView(QGraphicsScene *scene, QWidget *parent = NULL) : QGraphicsView(scene, parent)
|
GraphicsView(QGraphicsScene *scene, QWidget *parent = nullptr)
|
||||||
|
: QGraphicsView(scene, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,9 @@
|
|||||||
#include <QtWidgets/QGraphicsScene>
|
#include <QtWidgets/QGraphicsScene>
|
||||||
#include <QtWidgets/QGraphicsView>
|
#include <QtWidgets/QGraphicsView>
|
||||||
|
|
||||||
GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView(parent), m_editor(0) {}
|
GraphicsView::GraphicsView(QWidget *parent)
|
||||||
|
: QGraphicsView(parent), m_editor(nullptr)
|
||||||
|
{}
|
||||||
|
|
||||||
void GraphicsView::keyPressEvent(QKeyEvent *e)
|
void GraphicsView::keyPressEvent(QKeyEvent *e)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,7 @@ class GraphicsView: public QGraphicsView
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GraphicsView(QWidget *parent = 0);
|
GraphicsView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
@ -175,10 +175,9 @@ void LifeCycle::addActivity(const QString &fileName, Qt::Key key, QObject *sende
|
|||||||
QState *state = makeState(m_alive, fileName);
|
QState *state = makeState(m_alive, fileName);
|
||||||
m_alive->addTransition(new KeyPressTransition(m_keyReceiver, key, state));
|
m_alive->addTransition(new KeyPressTransition(m_keyReceiver, key, state));
|
||||||
|
|
||||||
if((sender != NULL) || (signal != NULL)) {
|
if (sender || signal)
|
||||||
m_alive->addTransition(sender, signal, state);
|
m_alive->addTransition(sender, signal, state);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName)
|
QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName)
|
||||||
{
|
{
|
||||||
@ -192,7 +191,7 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int frameCount = animation.totalFrames();
|
const int frameCount = animation.totalFrames();
|
||||||
QState *previousState = 0;
|
QState *previousState = nullptr;
|
||||||
for (int i=0; i<frameCount; ++i) {
|
for (int i=0; i<frameCount; ++i) {
|
||||||
animation.setCurrentFrame(i);
|
animation.setCurrentFrame(i);
|
||||||
|
|
||||||
@ -204,7 +203,7 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa
|
|||||||
//! [1]
|
//! [1]
|
||||||
|
|
||||||
frameState->setObjectName(QString::fromLatin1("frame %0").arg(i));
|
frameState->setObjectName(QString::fromLatin1("frame %0").arg(i));
|
||||||
if (previousState == 0)
|
if (previousState == nullptr)
|
||||||
topLevel->setInitialState(frameState);
|
topLevel->setInitialState(frameState);
|
||||||
else
|
else
|
||||||
//! [2]
|
//! [2]
|
||||||
|
@ -176,8 +176,7 @@ Node *StickMan::node(int idx) const
|
|||||||
{
|
{
|
||||||
if (idx >= 0 && idx < NodeCount)
|
if (idx >= 0 && idx < NodeCount)
|
||||||
return m_nodes[idx];
|
return m_nodes[idx];
|
||||||
else
|
return nullptr;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickMan::timerEvent(QTimerEvent *)
|
void StickMan::timerEvent(QTimerEvent *)
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
// the universe's only animation manager
|
// the universe's only animation manager
|
||||||
AnimationManager *AnimationManager::instance = 0;
|
AnimationManager *AnimationManager::instance = nullptr;
|
||||||
|
|
||||||
AnimationManager::AnimationManager()
|
AnimationManager::AnimationManager()
|
||||||
{
|
{
|
||||||
|
@ -92,8 +92,9 @@ static QAbstractAnimation *setupDestroyAnimation(Boat *boat)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Boat::Boat() : PixmapItem(QString("boat"), GraphicsScene::Big),
|
Boat::Boat()
|
||||||
speed(0), bombsAlreadyLaunched(0), direction(Boat::None), movementAnimation(0)
|
: PixmapItem(QString("boat"), GraphicsScene::Big),
|
||||||
|
speed(0), bombsAlreadyLaunched(0), direction(Boat::None)
|
||||||
{
|
{
|
||||||
setZValue(4);
|
setZValue(4);
|
||||||
setFlags(QGraphicsItem::ItemIsFocusable);
|
setFlags(QGraphicsItem::ItemIsFocusable);
|
||||||
|
@ -146,7 +146,8 @@ private:
|
|||||||
class MoveStateRight : public QState
|
class MoveStateRight : public QState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MoveStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
|
explicit MoveStateRight(Boat *boat, QState *parent = nullptr)
|
||||||
|
: QState(parent), boat(boat)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
@ -163,7 +164,8 @@ private:
|
|||||||
class MoveStateLeft : public QState
|
class MoveStateLeft : public QState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MoveStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
|
explicit MoveStateLeft(Boat *boat, QState *parent = nullptr)
|
||||||
|
: QState(parent), boat(boat)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
@ -180,7 +182,8 @@ private:
|
|||||||
class StopState : public QState
|
class StopState : public QState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit StopState(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
|
explicit StopState(Boat *boat, QState *parent = nullptr)
|
||||||
|
: QState(parent), boat(boat)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
@ -198,13 +201,14 @@ private:
|
|||||||
class LaunchStateRight : public QState
|
class LaunchStateRight : public QState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit LaunchStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
|
explicit LaunchStateRight(Boat *boat, QState *parent = nullptr)
|
||||||
|
: QState(parent), boat(boat)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
void onEntry(QEvent *) override
|
void onEntry(QEvent *) override
|
||||||
{
|
{
|
||||||
Bomb *b = new Bomb();
|
Bomb *b = new Bomb;
|
||||||
b->setPos(boat->x()+boat->size().width(),boat->y());
|
b->setPos(boat->x()+boat->size().width(),boat->y());
|
||||||
GraphicsScene *scene = static_cast<GraphicsScene *>(boat->scene());
|
GraphicsScene *scene = static_cast<GraphicsScene *>(boat->scene());
|
||||||
scene->addItem(b);
|
scene->addItem(b);
|
||||||
@ -219,13 +223,14 @@ private:
|
|||||||
class LaunchStateLeft : public QState
|
class LaunchStateLeft : public QState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit LaunchStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
|
explicit LaunchStateLeft(Boat *boat, QState *parent = nullptr)
|
||||||
|
: QState(parent), boat(boat)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
void onEntry(QEvent *) override
|
void onEntry(QEvent *) override
|
||||||
{
|
{
|
||||||
Bomb *b = new Bomb();
|
Bomb *b = new Bomb;
|
||||||
b->setPos(boat->x() - b->size().width(), boat->y());
|
b->setPos(boat->x() - b->size().width(), boat->y());
|
||||||
GraphicsScene *scene = static_cast<GraphicsScene *>(boat->scene());
|
GraphicsScene *scene = static_cast<GraphicsScene *>(boat->scene());
|
||||||
scene->addItem(b);
|
scene->addItem(b);
|
||||||
|
@ -63,7 +63,8 @@
|
|||||||
# include <QtOpenGL/QtOpenGL>
|
# include <QtOpenGL/QtOpenGL>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MainWindow::MainWindow() : QMainWindow(0)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
|
: QMainWindow(parent)
|
||||||
{
|
{
|
||||||
QMenu *file = menuBar()->addMenu(tr("&File"));
|
QMenu *file = menuBar()->addMenu(tr("&File"));
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class MainWindow : public QMainWindow
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow(QWidget *parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GraphicsScene *scene;
|
GraphicsScene *scene;
|
||||||
|
@ -54,7 +54,8 @@
|
|||||||
//Qt
|
//Qt
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsObject(parent)
|
PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent)
|
||||||
|
: QGraphicsObject(parent)
|
||||||
{
|
{
|
||||||
if (mode == GraphicsScene::Big)
|
if (mode == GraphicsScene::Big)
|
||||||
pix = QPixmap(QStringLiteral(":/big/") + fileName);
|
pix = QPixmap(QStringLiteral(":/big/") + fileName);
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
class PixmapItem : public QGraphicsObject
|
class PixmapItem : public QGraphicsObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem * parent = 0);
|
PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem *parent = nullptr);
|
||||||
PixmapItem(const QString &fileName, QGraphicsScene *scene);
|
PixmapItem(const QString &fileName, QGraphicsScene *scene);
|
||||||
QSizeF size() const;
|
QSizeF size() const;
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
|
@ -84,7 +84,7 @@ machine.start();
|
|||||||
Constructs a new state with the given \a parent state.
|
Constructs a new state with the given \a parent state.
|
||||||
*/
|
*/
|
||||||
QAnimationState::QAnimationState(QState *parent)
|
QAnimationState::QAnimationState(QState *parent)
|
||||||
: QState(parent), m_animation(0)
|
: QState(parent), m_animation(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +67,8 @@
|
|||||||
#include <QtCore/QRandomGenerator>
|
#include <QtCore/QRandomGenerator>
|
||||||
|
|
||||||
PlayState::PlayState(GraphicsScene *scene, QState *parent)
|
PlayState::PlayState(GraphicsScene *scene, QState *parent)
|
||||||
: QState(parent),
|
: QState(parent), scene(scene), machine(nullptr),
|
||||||
scene(scene),
|
currentLevel(0), score(0)
|
||||||
machine(0),
|
|
||||||
currentLevel(0),
|
|
||||||
score(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ int main(int argc, char *argv[])
|
|||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
QMessageBox::critical(0, QObject::tr("Systray"),
|
QMessageBox::critical(nullptr, QObject::tr("Systray"),
|
||||||
QObject::tr("I couldn't detect any system tray "
|
QObject::tr("I couldn't detect any system tray "
|
||||||
"on this system."));
|
"on this system."));
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -176,7 +176,7 @@ void Window::showMessage()
|
|||||||
//! [6]
|
//! [6]
|
||||||
void Window::messageClicked()
|
void Window::messageClicked()
|
||||||
{
|
{
|
||||||
QMessageBox::information(0, tr("Systray"),
|
QMessageBox::information(nullptr, tr("Systray"),
|
||||||
tr("Sorry, I already gave what help I could.\n"
|
tr("Sorry, I already gave what help I could.\n"
|
||||||
"Maybe you should try asking a human?"));
|
"Maybe you should try asking a human?"));
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ void ClassWizard::accept()
|
|||||||
|
|
||||||
QFile headerFile(outputDir + '/' + header);
|
QFile headerFile(outputDir + '/' + header);
|
||||||
if (!headerFile.open(QFile::WriteOnly | QFile::Text)) {
|
if (!headerFile.open(QFile::WriteOnly | QFile::Text)) {
|
||||||
QMessageBox::warning(0, QObject::tr("Simple Wizard"),
|
QMessageBox::warning(nullptr, QObject::tr("Simple Wizard"),
|
||||||
QObject::tr("Cannot write file %1:\n%2")
|
QObject::tr("Cannot write file %1:\n%2")
|
||||||
.arg(headerFile.fileName())
|
.arg(headerFile.fileName())
|
||||||
.arg(headerFile.errorString()));
|
.arg(headerFile.errorString()));
|
||||||
@ -195,7 +195,7 @@ void ClassWizard::accept()
|
|||||||
|
|
||||||
QFile implementationFile(outputDir + '/' + implementation);
|
QFile implementationFile(outputDir + '/' + implementation);
|
||||||
if (!implementationFile.open(QFile::WriteOnly | QFile::Text)) {
|
if (!implementationFile.open(QFile::WriteOnly | QFile::Text)) {
|
||||||
QMessageBox::warning(0, QObject::tr("Simple Wizard"),
|
QMessageBox::warning(nullptr, QObject::tr("Simple Wizard"),
|
||||||
QObject::tr("Cannot write file %1:\n%2")
|
QObject::tr("Cannot write file %1:\n%2")
|
||||||
.arg(implementationFile.fileName())
|
.arg(implementationFile.fileName())
|
||||||
.arg(implementationFile.errorString()));
|
.arg(implementationFile.errorString()));
|
||||||
|
@ -182,7 +182,7 @@ QStringList Window::findFiles(const QStringList &files, const QString &text)
|
|||||||
|
|
||||||
for (int i = 0; i < files.size(); ++i) {
|
for (int i = 0; i < files.size(); ++i) {
|
||||||
progressDialog.setValue(i);
|
progressDialog.setValue(i);
|
||||||
progressDialog.setLabelText(tr("Searching file number %1 of %n...", 0, files.size()).arg(i));
|
progressDialog.setLabelText(tr("Searching file number %1 of %n...", nullptr, files.size()).arg(i));
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
//! [6]
|
//! [6]
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ void Window::showFiles(const QStringList &paths)
|
|||||||
filesTable->setItem(row, 0, fileNameItem);
|
filesTable->setItem(row, 0, fileNameItem);
|
||||||
filesTable->setItem(row, 1, sizeItem);
|
filesTable->setItem(row, 1, sizeItem);
|
||||||
}
|
}
|
||||||
filesFoundLabel->setText(tr("%n file(s) found (Double click on a file to open it)", 0, paths.size()));
|
filesFoundLabel->setText(tr("%n file(s) found (Double click on a file to open it)", nullptr, paths.size()));
|
||||||
filesFoundLabel->setWordWrap(true);
|
filesFoundLabel->setWordWrap(true);
|
||||||
}
|
}
|
||||||
//! [8]
|
//! [8]
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
class DialogOptionsWidget : public QGroupBox
|
class DialogOptionsWidget : public QGroupBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DialogOptionsWidget(QWidget *parent = 0);
|
explicit DialogOptionsWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void addCheckBox(const QString &text, int value);
|
void addCheckBox(const QString &text, int value);
|
||||||
void addSpacer();
|
void addSpacer();
|
||||||
@ -492,7 +492,7 @@ void Dialog::questionMessage()
|
|||||||
void Dialog::warningMessage()
|
void Dialog::warningMessage()
|
||||||
{
|
{
|
||||||
QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"),
|
QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"),
|
||||||
MESSAGE, 0, this);
|
MESSAGE, nullptr, this);
|
||||||
msgBox.setDetailedText(MESSAGE_DETAILS);
|
msgBox.setDetailedText(MESSAGE_DETAILS);
|
||||||
msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole);
|
msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole);
|
||||||
msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole);
|
msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole);
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
|
|
||||||
CustomProxy::CustomProxy(QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
CustomProxy::CustomProxy(QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
||||||
: QGraphicsProxyWidget(parent, wFlags), popupShown(false), currentPopup(0)
|
: QGraphicsProxyWidget(parent, wFlags), popupShown(false), currentPopup(nullptr)
|
||||||
{
|
{
|
||||||
timeLine = new QTimeLine(250, this);
|
timeLine = new QTimeLine(250, this);
|
||||||
connect(timeLine, &QTimeLine::valueChanged,
|
connect(timeLine, &QTimeLine::valueChanged,
|
||||||
@ -133,7 +133,7 @@ QVariant CustomProxy::itemChange(GraphicsItemChange change, const QVariant &valu
|
|||||||
currentPopup->installSceneEventFilter(this);
|
currentPopup->installSceneEventFilter(this);
|
||||||
} else if (scene()) {
|
} else if (scene()) {
|
||||||
currentPopup->removeSceneEventFilter(this);
|
currentPopup->removeSceneEventFilter(this);
|
||||||
currentPopup = 0;
|
currentPopup = nullptr;
|
||||||
}
|
}
|
||||||
} else if (currentPopup && change == ItemSceneHasChanged) {
|
} else if (currentPopup && change == ItemSceneHasChanged) {
|
||||||
currentPopup->installSceneEventFilter(this);
|
currentPopup->installSceneEventFilter(this);
|
||||||
|
@ -66,7 +66,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (int y = 0; y < gridSize; ++y) {
|
for (int y = 0; y < gridSize; ++y) {
|
||||||
for (int x = 0; x < gridSize; ++x) {
|
for (int x = 0; x < gridSize; ++x) {
|
||||||
CustomProxy *proxy = new CustomProxy(0, Qt::Window);
|
CustomProxy *proxy = new CustomProxy(nullptr, Qt::Window);
|
||||||
proxy->setWidget(new EmbeddedDialog);
|
proxy->setWidget(new EmbeddedDialog);
|
||||||
|
|
||||||
QRectF rect = proxy->boundingRect();
|
QRectF rect = proxy->boundingRect();
|
||||||
|
@ -98,10 +98,7 @@ int BorderLayout::count() const
|
|||||||
QLayoutItem *BorderLayout::itemAt(int index) const
|
QLayoutItem *BorderLayout::itemAt(int index) const
|
||||||
{
|
{
|
||||||
ItemWrapper *wrapper = list.value(index);
|
ItemWrapper *wrapper = list.value(index);
|
||||||
if (wrapper)
|
return wrapper ? wrapper->item : nullptr;
|
||||||
return wrapper->item;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize BorderLayout::minimumSize() const
|
QSize BorderLayout::minimumSize() const
|
||||||
@ -111,7 +108,7 @@ QSize BorderLayout::minimumSize() const
|
|||||||
|
|
||||||
void BorderLayout::setGeometry(const QRect &rect)
|
void BorderLayout::setGeometry(const QRect &rect)
|
||||||
{
|
{
|
||||||
ItemWrapper *center = 0;
|
ItemWrapper *center = nullptr;
|
||||||
int eastWidth = 0;
|
int eastWidth = 0;
|
||||||
int westWidth = 0;
|
int westWidth = 0;
|
||||||
int northHeight = 0;
|
int northHeight = 0;
|
||||||
@ -189,7 +186,7 @@ QLayoutItem *BorderLayout::takeAt(int index)
|
|||||||
ItemWrapper *layoutStruct = list.takeAt(index);
|
ItemWrapper *layoutStruct = list.takeAt(index);
|
||||||
return layoutStruct->item;
|
return layoutStruct->item;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BorderLayout::add(QLayoutItem *item, Position position)
|
void BorderLayout::add(QLayoutItem *item, Position position)
|
||||||
|
@ -116,8 +116,7 @@ QLayoutItem *FlowLayout::takeAt(int index)
|
|||||||
{
|
{
|
||||||
if (index >= 0 && index < itemList.size())
|
if (index >= 0 && index < itemList.size())
|
||||||
return itemList.takeAt(index);
|
return itemList.takeAt(index);
|
||||||
else
|
return nullptr;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
//! [5]
|
//! [5]
|
||||||
|
|
||||||
@ -215,7 +214,7 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
|
|||||||
return -1;
|
return -1;
|
||||||
} else if (parent->isWidgetType()) {
|
} else if (parent->isWidgetType()) {
|
||||||
QWidget *pw = static_cast<QWidget *>(parent);
|
QWidget *pw = static_cast<QWidget *>(parent);
|
||||||
return pw->style()->pixelMetric(pm, 0, pw);
|
return pw->style()->pixelMetric(pm, nullptr, pw);
|
||||||
} else {
|
} else {
|
||||||
return static_cast<QLayout *>(parent)->spacing();
|
return static_cast<QLayout *>(parent)->spacing();
|
||||||
}
|
}
|
||||||
|
@ -584,7 +584,7 @@ void ColorSwatch::changeVerticalTitleBar(bool on)
|
|||||||
QSize BlueTitleBar::minimumSizeHint() const
|
QSize BlueTitleBar::minimumSizeHint() const
|
||||||
{
|
{
|
||||||
QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
|
QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
|
||||||
Q_ASSERT(dw != 0);
|
Q_ASSERT(dw);
|
||||||
QSize result(leftPm.width() + rightPm.width(), centerPm.height());
|
QSize result(leftPm.width() + rightPm.width(), centerPm.height());
|
||||||
if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar)
|
if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar)
|
||||||
result.transpose();
|
result.transpose();
|
||||||
@ -605,7 +605,7 @@ void BlueTitleBar::paintEvent(QPaintEvent*)
|
|||||||
QRect rect = this->rect();
|
QRect rect = this->rect();
|
||||||
|
|
||||||
QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
|
QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
|
||||||
Q_ASSERT(dw != 0);
|
Q_ASSERT(dw);
|
||||||
|
|
||||||
if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
|
if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
|
||||||
QSize s = rect.size();
|
QSize s = rect.size();
|
||||||
@ -632,7 +632,7 @@ void BlueTitleBar::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
QRect rect = this->rect();
|
QRect rect = this->rect();
|
||||||
|
|
||||||
QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
|
QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
|
||||||
Q_ASSERT(dw != 0);
|
Q_ASSERT(dw);
|
||||||
|
|
||||||
if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
|
if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
|
||||||
QPoint p = pos;
|
QPoint p = pos;
|
||||||
@ -676,7 +676,7 @@ void BlueTitleBar::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
void BlueTitleBar::updateMask()
|
void BlueTitleBar::updateMask()
|
||||||
{
|
{
|
||||||
QDockWidget *dw = qobject_cast<QDockWidget*>(parent());
|
QDockWidget *dw = qobject_cast<QDockWidget*>(parent());
|
||||||
Q_ASSERT(dw != 0);
|
Q_ASSERT(dw);
|
||||||
|
|
||||||
QRect rect = dw->rect();
|
QRect rect = dw->rect();
|
||||||
QPixmap bitmap(dw->size());
|
QPixmap bitmap(dw->size());
|
||||||
|
@ -208,7 +208,7 @@ ToolBar::ToolBar(const QString &title, QWidget *parent)
|
|||||||
void ToolBar::updateMenu()
|
void ToolBar::updateMenu()
|
||||||
{
|
{
|
||||||
QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
|
QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
|
||||||
Q_ASSERT(mainWindow != 0);
|
Q_ASSERT(mainWindow);
|
||||||
|
|
||||||
const Qt::ToolBarArea area = mainWindow->toolBarArea(this);
|
const Qt::ToolBarArea area = mainWindow->toolBarArea(this);
|
||||||
const Qt::ToolBarAreas areas = allowedAreas();
|
const Qt::ToolBarAreas areas = allowedAreas();
|
||||||
@ -313,7 +313,7 @@ void ToolBar::place(Qt::ToolBarArea area, bool p)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
|
QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
|
||||||
Q_ASSERT(mainWindow != 0);
|
Q_ASSERT(mainWindow);
|
||||||
|
|
||||||
mainWindow->addToolBar(area, this);
|
mainWindow->addToolBar(area, this);
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ void ToolBar::placeBottom(bool p)
|
|||||||
void ToolBar::insertToolBarBreak()
|
void ToolBar::insertToolBarBreak()
|
||||||
{
|
{
|
||||||
QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
|
QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
|
||||||
Q_ASSERT(mainWindow != 0);
|
Q_ASSERT(mainWindow);
|
||||||
|
|
||||||
mainWindow->insertToolBarBreak(this);
|
mainWindow->insertToolBarBreak(this);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ void MainWindow::about()
|
|||||||
|
|
||||||
void MainWindow::updateMenus()
|
void MainWindow::updateMenus()
|
||||||
{
|
{
|
||||||
bool hasMdiChild = (activeMdiChild() != 0);
|
bool hasMdiChild = (activeMdiChild() != nullptr);
|
||||||
saveAct->setEnabled(hasMdiChild);
|
saveAct->setEnabled(hasMdiChild);
|
||||||
saveAsAct->setEnabled(hasMdiChild);
|
saveAsAct->setEnabled(hasMdiChild);
|
||||||
#ifndef QT_NO_CLIPBOARD
|
#ifndef QT_NO_CLIPBOARD
|
||||||
@ -483,7 +483,7 @@ MdiChild *MainWindow::activeMdiChild() const
|
|||||||
{
|
{
|
||||||
if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow())
|
if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow())
|
||||||
return qobject_cast<MdiChild *>(activeSubWindow->widget());
|
return qobject_cast<MdiChild *>(activeSubWindow->widget());
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMdiSubWindow *MainWindow::findMdiChild(const QString &fileName) const
|
QMdiSubWindow *MainWindow::findMdiChild(const QString &fileName) const
|
||||||
@ -495,7 +495,7 @@ QMdiSubWindow *MainWindow::findMdiChild(const QString &fileName) const
|
|||||||
if (mdiChild->currentFile() == canonicalFilePath)
|
if (mdiChild->currentFile() == canonicalFilePath)
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::switchLayoutDirection()
|
void MainWindow::switchLayoutDirection()
|
||||||
|
@ -478,5 +478,5 @@ MainWindow *MainWindow::findMainWindow(const QString &fileName) const
|
|||||||
return mainWin;
|
return mainWin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class AnalogClock : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AnalogClock(QWidget *parent = 0);
|
AnalogClock(QWidget *parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
@ -59,7 +59,7 @@ class Button : public QToolButton
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Button(const QString &text, QWidget *parent = 0);
|
explicit Button(const QString &text, QWidget *parent = nullptr);
|
||||||
|
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
};
|
};
|
||||||
|
@ -64,7 +64,7 @@ class Calculator : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Calculator(QWidget *parent = 0);
|
Calculator(QWidget *parent = nullptr);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void digitClicked();
|
void digitClicked();
|
||||||
|
@ -68,7 +68,7 @@ class CharacterWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CharacterWidget(QWidget *parent = 0);
|
CharacterWidget(QWidget *parent = nullptr);
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -188,7 +188,7 @@ void MainWindow::filterChanged(int f)
|
|||||||
const QFontComboBox::FontFilter filter =
|
const QFontComboBox::FontFilter filter =
|
||||||
filterCombo->itemData(f).value<QFontComboBox::FontFilter>();
|
filterCombo->itemData(f).value<QFontComboBox::FontFilter>();
|
||||||
fontCombo->setFontFilters(filter);
|
fontCombo->setFontFilters(filter);
|
||||||
statusBar()->showMessage(tr("%n font(s) found", 0, fontCombo->count()));
|
statusBar()->showMessage(tr("%n font(s) found", nullptr, fontCombo->count()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::findSizes(const QFont &font)
|
void MainWindow::findSizes(const QFont &font)
|
||||||
|
@ -70,7 +70,7 @@ class CodeEditor : public QPlainTextEdit
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CodeEditor(QWidget *parent = 0);
|
CodeEditor(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void lineNumberAreaPaintEvent(QPaintEvent *event);
|
void lineNumberAreaPaintEvent(QPaintEvent *event);
|
||||||
int lineNumberAreaWidth();
|
int lineNumberAreaWidth();
|
||||||
|
@ -59,7 +59,7 @@ class DigitalClock : public QLCDNumber
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DigitalClock(QWidget *parent = 0);
|
DigitalClock(QWidget *parent = nullptr);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showTime();
|
void showTime();
|
||||||
|
@ -65,7 +65,7 @@ class ElidedLabel : public QFrame
|
|||||||
Q_PROPERTY(bool isElided READ isElided)
|
Q_PROPERTY(bool isElided READ isElided)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ElidedLabel(const QString &text, QWidget *parent = 0);
|
explicit ElidedLabel(const QString &text, QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
const QString & text() const { return content; }
|
const QString & text() const { return content; }
|
||||||
|
@ -64,7 +64,7 @@ class TestWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestWidget(QWidget *parent = 0);
|
TestWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
@ -63,7 +63,7 @@ class Window : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Window(QWidget *parent = 0);
|
Window(QWidget *parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGroupBox *createFirstExclusiveGroup();
|
QGroupBox *createFirstExclusiveGroup();
|
||||||
|
@ -206,7 +206,7 @@ void Window::validatorChanged(int index)
|
|||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
validatorLineEdit->setValidator(0);
|
validatorLineEdit->setValidator(nullptr);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
validatorLineEdit->setValidator(new QIntValidator(
|
validatorLineEdit->setValidator(new QIntValidator(
|
||||||
|
@ -70,7 +70,7 @@ class MoviePlayer : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MoviePlayer(QWidget *parent = 0);
|
MoviePlayer(QWidget *parent = nullptr);
|
||||||
void openFile(const QString &fileName);
|
void openFile(const QString &fileName);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -62,7 +62,7 @@ class ScribbleArea : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScribbleArea(QWidget *parent = 0);
|
ScribbleArea(QWidget *parent = nullptr);
|
||||||
|
|
||||||
bool openImage(const QString &fileName);
|
bool openImage(const QString &fileName);
|
||||||
bool saveImage(const QString &fileName, const char *fileFormat);
|
bool saveImage(const QString &fileName, const char *fileFormat);
|
||||||
|
@ -59,7 +59,7 @@ class ShapedClock : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ShapedClock(QWidget *parent = 0);
|
ShapedClock(QWidget *parent = nullptr);
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -66,7 +66,7 @@ class SlidersGroup : public QGroupBox
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
SlidersGroup(Qt::Orientation orientation, const QString &title,
|
SlidersGroup(Qt::Orientation orientation, const QString &title,
|
||||||
QWidget *parent = 0);
|
QWidget *parent = nullptr);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void valueChanged(int value);
|
void valueChanged(int value);
|
||||||
|
@ -78,7 +78,7 @@ class WidgetGallery : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WidgetGallery(QWidget *parent = 0);
|
WidgetGallery(QWidget *parent = nullptr);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void changeStyle(const QString &styleName);
|
void changeStyle(const QString &styleName);
|
||||||
|
@ -60,7 +60,7 @@ class StyleSheetEditor : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StyleSheetEditor(QWidget *parent = 0);
|
StyleSheetEditor(QWidget *parent = nullptr);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_styleCombo_activated(const QString &styleName);
|
void on_styleCombo_activated(const QString &styleName);
|
||||||
|
@ -61,15 +61,14 @@ class TabletApplication : public QApplication
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TabletApplication(int &argv, char **args)
|
using QApplication::QApplication;
|
||||||
: QApplication(argv, args) {}
|
|
||||||
|
|
||||||
bool event(QEvent *event) override;
|
bool event(QEvent *event) override;
|
||||||
void setCanvas(TabletCanvas *canvas)
|
void setCanvas(TabletCanvas *canvas)
|
||||||
{ m_canvas = canvas; }
|
{ m_canvas = canvas; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TabletCanvas *m_canvas;
|
TabletCanvas *m_canvas = nullptr;
|
||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class TetrixBoard : public QFrame
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TetrixBoard(QWidget *parent = 0);
|
TetrixBoard(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setNextPieceLabel(QLabel *label);
|
void setNextPieceLabel(QLabel *label);
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
@ -64,7 +64,7 @@ SortingBox::SortingBox(QWidget *parent)
|
|||||||
setBackgroundRole(QPalette::Base);
|
setBackgroundRole(QPalette::Base);
|
||||||
//! [2]
|
//! [2]
|
||||||
|
|
||||||
itemInMotion = 0;
|
itemInMotion = nullptr;
|
||||||
|
|
||||||
//! [3]
|
//! [3]
|
||||||
newCircleButton = createToolButton(tr("New Circle"),
|
newCircleButton = createToolButton(tr("New Circle"),
|
||||||
@ -179,7 +179,7 @@ void SortingBox::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && itemInMotion) {
|
if (event->button() == Qt::LeftButton && itemInMotion) {
|
||||||
moveItemTo(event->pos());
|
moveItemTo(event->pos());
|
||||||
itemInMotion = 0;
|
itemInMotion = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//! [13]
|
//! [13]
|
||||||
|
@ -59,7 +59,7 @@ class LEDWidget : public QLabel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
LEDWidget(QWidget *parent = 0);
|
LEDWidget(QWidget *parent = nullptr);
|
||||||
public slots:
|
public slots:
|
||||||
void flash();
|
void flash();
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class LocaleSelector : public QComboBox
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LocaleSelector(QWidget *parent = 0);
|
LocaleSelector(QWidget *parent = nullptr);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void localeSelected(const QLocale &locale);
|
void localeSelected(const QLocale &locale);
|
||||||
|
@ -59,7 +59,7 @@ class Dialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Dialog(QWidget *parent = 0);
|
explicit Dialog(QWidget *parent = nullptr);
|
||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class WigglyWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WigglyWidget(QWidget *parent = 0);
|
WigglyWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setText(const QString &newText) { text = newText; }
|
void setText(const QString &newText) { text = newText; }
|
||||||
|
@ -64,7 +64,7 @@ class PreviewWindow : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PreviewWindow(QWidget *parent = 0);
|
PreviewWindow(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setWindowFlags(Qt::WindowFlags flags);
|
void setWindowFlags(Qt::WindowFlags flags);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user