Whitespace cleanup: remove trailing whitespace

Remove all trailing whitespace from the following list of files:
*.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README
excluding 3rdparty, test-data and auto generated code.

Note A): the only non 3rdparty c++-files that still
have trailing whitespace after this change are:
* src/corelib/codecs/cp949codetbl_p.h
* src/corelib/codecs/qjpunicode.cpp
* src/corelib/codecs/qbig5codec.cpp
* src/corelib/xml/qxmlstream_p.h
* src/tools/qdoc/qmlparser/qqmljsgrammar.cpp
* src/tools/uic/ui4.cpp
* tests/auto/other/qtokenautomaton/tokenizers/*
* tests/benchmarks/corelib/tools/qstring/data.cpp
* util/lexgen/tokenizer.cpp

Note B): in about 30 files some overlapping 'leading tab' and
'TAB character in non-leading whitespace' issues have been fixed
to make the sanity bot happy. Plus some general ws-fixes here
and there as asked for during review.

Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
Axel Waggershauser 2013-03-15 00:42:15 +01:00 committed by The Qt Project
parent 72367a94a7
commit b11317a643
594 changed files with 3518 additions and 3541 deletions

View File

@ -50,7 +50,7 @@ int main(int, char **)
#else
# error "Feature _POSIX_MONOTONIC_CLOCK not available"
// MIPSpro doesn't understand #error, so force a compiler error
force_compiler_error = true;
force_compiler_error = true;
#endif
return 0;
}

View File

@ -59,6 +59,6 @@ int main()
if (getaddrinfo("foo", 0, 0, &res) == 0)
freeaddrinfo(res);
gai_strerror(0);
return 0;
}

View File

@ -61,7 +61,7 @@
message to be sent.
The \c Message class is defined in the following way:
\snippet examples/tools/customtypesending/message.h custom type definition
The type is declared to the meta-type system with the Q_DECLARE_METATYPE()

View File

@ -82,7 +82,7 @@ void Ping::start(const QString &name, const QString &oldValue, const QString &ne
if (!reply.isNull())
printf("value = %s\n", qPrintable(reply.toString()));
} else if (line.startsWith("value=")) {
iface->setProperty("value", line.mid(6));
iface->setProperty("value", line.mid(6));
} else {
QDBusReply<QDBusVariant> reply = iface->call("query", line);
if (reply.isValid())
@ -92,7 +92,7 @@ void Ping::start(const QString &name, const QString &oldValue, const QString &ne
if (iface->lastError().isValid())
fprintf(stderr, "Call failed: %s\n", qPrintable(iface->lastError().message()));
}
}
}
int main(int argc, char **argv)
{

View File

@ -94,10 +94,10 @@ int main(int argc, char **argv)
if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
fprintf(stderr, "%s\n",
qPrintable(QDBusConnection::sessionBus().lastError().message()));
qPrintable(QDBusConnection::sessionBus().lastError().message()));
exit(1);
}
app.exec();
return 0;
}

View File

@ -67,13 +67,13 @@ int main(int argc, char **argv)
if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
fprintf(stderr, "%s\n",
qPrintable(QDBusConnection::sessionBus().lastError().message()));
qPrintable(QDBusConnection::sessionBus().lastError().message()));
exit(1);
}
Pong pong;
QDBusConnection::sessionBus().registerObject("/", &pong, QDBusConnection::ExportAllSlots);
app.exec();
return 0;
}

View File

@ -182,7 +182,7 @@ void Dialog::loadFromMemory()
*/
void Dialog::detach()
{
if (!sharedMemory.detach())
if (!sharedMemory.detach())
ui.label->setText(tr("Unable to detach from shared memory."));
}

View File

@ -43,7 +43,7 @@
QTcpSocket::connectToHost() returns immediately, and when the connection
has been established, QTcpSocket emits
\l{QTcpSocket::connected()}{connected()}.
\li \e{The synchronous (blocking) approach.} In non-GUI and multithreaded
applications, you can call the \c waitFor...() functions (e.g.,
QTcpSocket::waitForConnected()) to suspend the calling thread until the
@ -208,7 +208,7 @@
\snippet blockingfortuneclient/blockingclient.cpp 3
\codeline
\snippet blockingfortuneclient/blockingclient.cpp 4
Here, we simply display the fortune we received as the argument.
\sa {Fortune Client Example}, {Fortune Server Example}

View File

@ -48,8 +48,8 @@
FortuneServer inherits QTcpServer and reimplements
QTcpServer::incomingConnection(). We also use it for storing the list of
random fortunes.
random fortunes.
\snippet threadedfortuneserver/fortuneserver.cpp 0
We use FortuneServer's constructor to simply generate the list of
@ -71,7 +71,7 @@
QThread::run(), and it has a signal for reporting errors.
\snippet threadedfortuneserver/fortunethread.cpp 0
FortuneThread's constructor simply stores the socket descriptor and
fortune text, so that they are available for run() later on.
@ -101,7 +101,7 @@
But unlike the previous example, we finish off by calling
QTcpSocket::waitForDisconnected(), which blocks the calling thread until
the socket has disconnected. Because we are running in a separate thread,
the GUI will remain responsive.
the GUI will remain responsive.
\sa {Fortune Server Example}, {Fortune Client Example}, {Blocking Fortune
Client Example}

View File

@ -180,7 +180,7 @@ void HttpWindow::httpFinished()
tr("Download failed: %1.")
.arg(reply->errorString()));
downloadButton->setEnabled(true);
} else if (!redirectionTarget.isNull()) {
} else if (!redirectionTarget.isNull()) {
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
if (QMessageBox::question(this, tr("HTTP"),
tr("Redirect to %1 ?").arg(newUrl.toString()),
@ -256,7 +256,7 @@ void HttpWindow::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
errorString += ", ";
errorString += error.errorString();
}
if (QMessageBox::warning(this, tr("HTTP"),
tr("One or more SSL errors has occurred: %1").arg(errorString),
QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {

View File

@ -57,7 +57,7 @@ class SslClient : public QWidget
public:
SslClient(QWidget *parent = 0);
~SslClient();
private slots:
void updateEnabledState();
void secureConnect();

View File

@ -117,14 +117,14 @@ void AddTorrentDialog::setTorrent(const QString &torrentFile)
if (lastDestinationDirectory.isEmpty())
lastDestinationDirectory = lastDirectory;
MetaInfo metaInfo;
QFile torrent(torrentFile);
if (!torrent.open(QFile::ReadOnly) || !metaInfo.parse(torrent.readAll())) {
enableOkButton();
return;
}
ui.torrentFile->setText(torrentFile);
ui.announceUrl->setText(metaInfo.announceUrl());
if (metaInfo.comment().isEmpty())

View File

@ -81,26 +81,26 @@ bool BencodeParser::getByteString(QByteArray *byteString)
const int contentSize = content.size();
int size = -1;
do {
char c = content.at(index);
if (c < '0' || c > '9') {
if (size == -1)
return false;
if (c != ':') {
errString = QString("Unexpected character at pos %1: %2")
.arg(index).arg(c);
return false;
}
++index;
break;
}
if (size == -1)
size = 0;
size *= 10;
size += c - '0';
char c = content.at(index);
if (c < '0' || c > '9') {
if (size == -1)
return false;
if (c != ':') {
errString = QString("Unexpected character at pos %1: %2")
.arg(index).arg(c);
return false;
}
++index;
break;
}
if (size == -1)
size = 0;
size *= 10;
size += c - '0';
} while (++index < contentSize);
if (byteString)
*byteString = content.mid(index, size);
*byteString = content.mid(index, size);
index += size;
return true;
}
@ -109,38 +109,38 @@ bool BencodeParser::getInteger(qint64 *integer)
{
const int contentSize = content.size();
if (content.at(index) != 'i')
return false;
return false;
++index;
qint64 num = -1;
bool negative = false;
do {
char c = content.at(index);
if (c < '0' || c > '9') {
if (num == -1) {
if (c != '-' || negative)
return false;
negative = true;
continue;
} else {
if (c != 'e') {
errString = QString("Unexpected character at pos %1: %2")
.arg(index).arg(c);
return false;
}
++index;
break;
}
}
if (num == -1)
num = 0;
num *= 10;
num += c - '0';
char c = content.at(index);
if (c < '0' || c > '9') {
if (num == -1) {
if (c != '-' || negative)
return false;
negative = true;
continue;
} else {
if (c != 'e') {
errString = QString("Unexpected character at pos %1: %2")
.arg(index).arg(c);
return false;
}
++index;
break;
}
}
if (num == -1)
num = 0;
num *= 10;
num += c - '0';
} while (++index < contentSize);
if (integer)
*integer = negative ? -num : num;
*integer = negative ? -num : num;
return true;
}
@ -148,38 +148,38 @@ bool BencodeParser::getList(QList<QVariant> *list)
{
const int contentSize = content.size();
if (content.at(index) != 'l')
return false;
return false;
QList<QVariant> tmp;
QList<QVariant> tmp;
++index;
do {
if (content.at(index) == 'e') {
++index;
break;
}
if (content.at(index) == 'e') {
++index;
break;
}
qint64 number;
QByteArray byteString;
QList<QVariant> tmpList;
QMap<QByteArray, QVariant> dictionary;
qint64 number;
QByteArray byteString;
QList<QVariant> tmpList;
QMap<QByteArray, QVariant> dictionary;
if (getInteger(&number))
tmp << number;
else if (getByteString(&byteString))
tmp << byteString;
else if (getList(&tmpList))
tmp << tmpList;
else if (getDictionary(&dictionary))
tmp << QVariant::fromValue<QMap<QByteArray, QVariant> >(dictionary);
else {
errString = QString("error at index %1").arg(index);
return false;
}
if (getInteger(&number))
tmp << number;
else if (getByteString(&byteString))
tmp << byteString;
else if (getList(&tmpList))
tmp << tmpList;
else if (getDictionary(&dictionary))
tmp << QVariant::fromValue<QMap<QByteArray, QVariant> >(dictionary);
else {
errString = QString("error at index %1").arg(index);
return false;
}
} while (index < contentSize);
if (list)
*list = tmp;
*list = tmp;
return true;
}
@ -187,48 +187,48 @@ bool BencodeParser::getDictionary(QMap<QByteArray, QVariant> *dictionary)
{
const int contentSize = content.size();
if (content.at(index) != 'd')
return false;
return false;
QMap<QByteArray, QVariant> tmp;
QMap<QByteArray, QVariant> tmp;
++index;
do {
if (content.at(index) == 'e') {
++index;
break;
}
if (content.at(index) == 'e') {
++index;
break;
}
QByteArray key;
if (!getByteString(&key))
break;
QByteArray key;
if (!getByteString(&key))
break;
if (key == "info")
infoStart = index;
if (key == "info")
infoStart = index;
qint64 number;
QByteArray byteString;
QList<QVariant> tmpList;
QMap<QByteArray, QVariant> dictionary;
qint64 number;
QByteArray byteString;
QList<QVariant> tmpList;
QMap<QByteArray, QVariant> dictionary;
if (getInteger(&number))
tmp.insert(key, number);
else if (getByteString(&byteString))
tmp.insert(key, byteString);
else if (getList(&tmpList))
tmp.insert(key, tmpList);
else if (getDictionary(&dictionary))
tmp.insert(key, QVariant::fromValue<QMap<QByteArray, QVariant> >(dictionary));
else {
errString = QString("error at index %1").arg(index);
return false;
}
if (getInteger(&number))
tmp.insert(key, number);
else if (getByteString(&byteString))
tmp.insert(key, byteString);
else if (getList(&tmpList))
tmp.insert(key, tmpList);
else if (getDictionary(&dictionary))
tmp.insert(key, QVariant::fromValue<QMap<QByteArray, QVariant> >(dictionary));
else {
errString = QString("error at index %1").arg(index);
return false;
}
if (key == "info")
infoLength = index - infoStart;
if (key == "info")
infoLength = index - infoStart;
} while (index < contentSize);
if (dictionary)
*dictionary = tmp;
*dictionary = tmp;
return true;
}

View File

@ -54,7 +54,7 @@ class BencodeParser
{
public:
BencodeParser();
bool parse(const QByteArray &content);
QString errorString() const;

View File

@ -65,7 +65,7 @@ public:
inline void setMetaInfo(const MetaInfo &info) { metaInfo = info; }
inline void setDestinationFolder(const QString &directory) { destinationPath = directory; }
int read(int pieceIndex, int offset, int length);
void write(int pieceIndex, int offset, const QByteArray &data);
void verifyPiece(int pieceIndex);

View File

@ -130,7 +130,7 @@ MainWindow::MainWindow(QWidget *parent)
QAction *newTorrentAction = new QAction(QIcon(":/icons/bottom.png"), tr("Add &new torrent"), this);
pauseTorrentAction = new QAction(QIcon(":/icons/player_pause.png"), tr("&Pause torrent"), this);
removeTorrentAction = new QAction(QIcon(":/icons/player_stop.png"), tr("&Remove torrent"), this);
// File menu
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(newTorrentAction);

View File

@ -65,7 +65,7 @@ public:
QSize sizeHint() const;
const TorrentClient *clientForRow(int row) const;
protected:
void closeEvent(QCloseEvent *event);
@ -94,12 +94,12 @@ private slots:
void about();
void setActionsEnabled();
void acceptFileDrop(const QString &fileName);
private:
int rowOfClient(TorrentClient *client) const;
bool addTorrent(const QString &fileName, const QString &destinationFolder,
const QByteArray &resumeState = QByteArray());
TorrentView *torrentView;
QAction *pauseTorrentAction;
QAction *removeTorrentAction;

View File

@ -100,7 +100,7 @@ public:
// Total size
qint64 totalSize() const;
private:
private:
QString errString;
QByteArray content;
QByteArray infoData;

View File

@ -63,7 +63,7 @@ struct TorrentBlock
&& offset == other.offset
&& length == other.length;
}
int pieceIndex;
int offset;
int length;

View File

@ -1020,7 +1020,7 @@ void TorrentClient::blockReceived(int pieceIndex, int begin, const QByteArray &d
if (blocksLeftForPiece(piece) == 0) {
// Ask the file manager to verify the newly downloaded piece
d->fileManager.verifyPiece(piece->index);
// Remove this piece from all payloads
QMultiMap<PeerWireClient *, TorrentPiece *>::Iterator it = d->payloads.begin();
while (it != d->payloads.end()) {
@ -1103,7 +1103,7 @@ void TorrentClient::scheduleUploads()
}
if ((client->peerWireState() & PeerWireClient::ChokingPeer) == 0) {
if ((qrand() % 10) == 0)
if ((qrand() % 10) == 0)
client->abort();
else
client->chokePeer();
@ -1245,7 +1245,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
if (d->state == WarmingUp || (qrand() & 4) == 0) {
int *occurrences = new int[d->pieceCount];
memset(occurrences, 0, d->pieceCount * sizeof(int));
// Count how many of each piece are available.
foreach (PeerWireClient *peer, d->connections) {
QBitArray peerPieces = peer->availablePieces();
@ -1342,7 +1342,7 @@ void TorrentClient::requestMore(PeerWireClient *client)
? MaxBlocksInMultiMode : MaxBlocksInProgress);
if (numBlocksInProgress == maxInProgress)
return;
// Starting with the first piece that we're waiting for, request
// blocks until the quota is filled up.
foreach (TorrentPiece *piece, piecesInProgress) {
@ -1446,7 +1446,7 @@ void TorrentClient::addToPeerList(const QList<TorrentPeer> &peerList)
// Skip our own server.
continue;
}
bool known = false;
foreach (TorrentPeer *knownPeer, d->peers) {
if (knownPeer->port == peer.port

View File

@ -124,7 +124,7 @@ public:
qint64 uploadedBytes() const;
int connectedPeerCount() const;
int seedCount() const;
// Accessors for the tracker
QByteArray peerId() const;
QByteArray infoHash() const;
@ -142,7 +142,7 @@ signals:
void downloadCompleted();
void peerInfoUpdated();
void dataSent(int uploadedBytes);
void dataReceived(int downloadedBytes);
void progressUpdated(int percentProgress);

View File

@ -74,7 +74,7 @@ signals:
void uploadCountUpdated(qint64 newUploadCount);
void downloadCountUpdated(qint64 newDownloadCount);
void stopped();
protected:
@ -99,7 +99,7 @@ private:
qint64 length;
QString uname;
QString pwd;
bool firstTrackerRequest;
bool lastTrackerRequest;
bool firstSeeding;

View File

@ -50,7 +50,7 @@ struct VertexData
};
GeometryEngine::GeometryEngine()
{
{
}
GeometryEngine::~GeometryEngine()

View File

@ -68,7 +68,7 @@ void MainWidget::mouseReleaseEvent(QMouseEvent *e)
// Mouse release position - mouse press position
QVector2D diff = QVector2D(e->localPos()) - mousePressPosition;
// Rotation axis is perpendicular to the mouse position difference
// Rotation axis is perpendicular to the mouse position difference
// vector
QVector3D n = QVector3D(diff.y(), diff.x(), 0.0).normalized();

View File

@ -116,7 +116,7 @@ void GLWidget::initializeGL()
gear3 = makeGear(reflectance3, 1.3, 2.0, 0.5, 0.7, 10);
glEnable(GL_NORMALIZE);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
void GLWidget::paintGL()

View File

@ -90,7 +90,7 @@ private:
int yRot;
int zRot;
int gear1Rot;
QPoint lastPos;
};

View File

@ -114,7 +114,7 @@ void Bubble::move(const QRect &bbox)
qreal rightOverflow = position.x() + radius - bbox.right();
qreal topOverflow = position.y() - radius - bbox.top();
qreal bottomOverflow = position.y() + radius - bbox.bottom();
if (leftOverflow < 0.0) {
position.setX(position.x() - 2 * leftOverflow);
vel.setX(-vel.x());

View File

@ -70,7 +70,7 @@ void GLWidget::setScaling(int scale) {
m_fScale = 1 + qreal(scale -50) / 50 * 0.5;
else if (scale < 50)
m_fScale = 1- (qreal(50 - scale) / 50 * 1/2);
else
else
m_fScale = 1;
}
@ -316,7 +316,7 @@ void GLWidget::paintGL()
painter.drawText(20, 40, framesPerSecond + " fps");
painter.end();
swapBuffers();
QMutableListIterator<Bubble*> iter(bubbles);

View File

@ -55,7 +55,7 @@ class GLWidget : public QGLWidget {
public:
GLWidget(QWidget *parent = 0);
~GLWidget();
public slots:
public slots:
void setScaling(int scale);
void setLogo();
void setTexture();

View File

@ -57,7 +57,7 @@ MainWindow::MainWindow()
QTimer *timer = new QTimer(this);
QSlider *slider = new QSlider(this);
slider->setOrientation(Qt::Horizontal);
slider->setRange(0, 100);
slider->setSliderPosition(50);
timer->setInterval(10);

View File

@ -85,7 +85,7 @@ void Bubble::move(const QRect &bbox)
qreal rightOverflow = position.x() + radius - bbox.right();
qreal topOverflow = position.y() - radius - bbox.top();
qreal bottomOverflow = position.y() + radius - bbox.bottom();
if (leftOverflow < 0.0) {
position.setX(position.x() - 2 * leftOverflow);
vel.setX(-vel.x());

View File

@ -50,8 +50,8 @@ QImage scale(const QString &imageFileName)
return image.scaled(QSize(imageSize, imageSize), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
Images::Images(QWidget *parent)
: QWidget(parent)
Images::Images(QWidget *parent)
: QWidget(parent)
{
setWindowTitle(tr("Image loading and scaling example"));
resize(800, 600);
@ -66,11 +66,11 @@ Images::Images(QWidget *parent)
cancelButton = new QPushButton(tr("Cancel"));
cancelButton->setEnabled(false);
connect(cancelButton, SIGNAL(clicked()), imageScaling, SLOT(cancel()));
pauseButton = new QPushButton(tr("Pause/Resume"));
pauseButton->setEnabled(false);
connect(pauseButton, SIGNAL(clicked()), imageScaling, SLOT(togglePaused()));
QHBoxLayout *buttonLayout = new QHBoxLayout();
buttonLayout->addWidget(openButton);
buttonLayout->addWidget(cancelButton);
@ -101,7 +101,7 @@ void Images::open()
}
// Show a file open dialog at QStandardPaths::PicturesLocation.
QStringList files = QFileDialog::getOpenFileNames(this, tr("Select Images"),
QStringList files = QFileDialog::getOpenFileNames(this, tr("Select Images"),
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation),
"*.jpg *.png");
@ -143,4 +143,3 @@ void Images::finished()
}
#endif // QT_NO_CONCURRENT

View File

@ -69,7 +69,7 @@ int main(int argc, char **argv)
// Create a progress dialog.
QProgressDialog dialog;
dialog.setLabelText(QString("Progressing using %1 thread(s)...").arg(QThread::idealThreadCount()));
// Create a QFutureWatcher and connect signals and slots.
QFutureWatcher<void> futureWatcher;
QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
@ -82,7 +82,7 @@ int main(int argc, char **argv)
// Display the dialog and start the event loop.
dialog.exec();
futureWatcher.waitForFinished();
// Query the future to check if was canceled.

View File

@ -81,7 +81,7 @@ void TestBenchmark::multiple()
QFETCH(bool, useLocaleCompare);
QString str1 = QLatin1String("This is a test string");
QString str2 = QLatin1String("This is a test string");
int result;
if (useLocaleCompare) {
QBENCHMARK {
@ -101,7 +101,7 @@ void TestBenchmark::series_data()
{
QTest::addColumn<bool>("useLocaleCompare");
QTest::addColumn<int>("stringSize");
for (int i = 1; i < 10000; i += 2000) {
QByteArray size = QByteArray::number(i);
QTest::newRow(("locale aware compare--" + size).constData()) << true << i;

View File

@ -32,7 +32,7 @@
\brief The Query Model example shows how to make customized versions of
data obtained from a SQL query, using a model that encapsulates
the query and table views to display the results.
the query and table views to display the results.
\image querymodel-example.png
*/

View File

@ -25,7 +25,7 @@
**
****************************************************************************/
/*!
/*!
\example relationaltablemodel
\title Relational Table Model Example
\ingroup sql_examples

View File

@ -25,7 +25,7 @@
**
****************************************************************************/
/*!
/*!
\example tablemodel
\title Table Model Example
\ingroup sql_examples

View File

@ -81,7 +81,7 @@ QImage createImage(int width, int height)
int x = 0;
int y = 0;
int starWidth = image.width()/3;
int starHeight = image.height()/3;
int starHeight = image.height()/3;
QRect rect(x, y, starWidth, starHeight);

View File

@ -70,7 +70,7 @@
And thats it. A perfectly reasonable cache, using minimal memory for a very large
list. In this case the accessor for getting the words into the cache
generates random information rather than fixed information. This allows you
generates random information rather than fixed information. This allows you
to see how the cache range is kept for a local number of rows when running the
example.

View File

@ -104,7 +104,7 @@
With the type fully defined, implemented, and integrated with the
meta-object system, we can now use it.
\section1 Using the Message
\section1 Using the Message
In the example's \c{main()} function, we show how a \c Message object can
be printed to the console by sending it to the debug stream:

View File

@ -158,7 +158,7 @@ void Mouse::timerEvent(QTimerEvent *)
foreach (QGraphicsItem *item, dangerMice) {
if (item == this)
continue;
QLineF lineToMouse(QPointF(0, 0), mapFromItem(item, 0, 0));
qreal angleToMouse = ::acos(lineToMouse.dx() / lineToMouse.length());
if (lineToMouse.dy() < 0)

View File

@ -108,7 +108,7 @@ void createStates(const QObjectList &objects,
void createAnimations(const QObjectList &objects, QStateMachine *machine)
{
for (int i=0; i<objects.size(); ++i)
machine->addDefaultAnimation(new QPropertyAnimation(objects.at(i), "geometry"));
machine->addDefaultAnimation(new QPropertyAnimation(objects.at(i), "geometry"));
}
int main(int argc, char **argv)

View File

@ -63,11 +63,11 @@ private slots:
void periodChanged(double);
void amplitudeChanged(double);
void overshootChanged(double);
private:
void createCurveIcons();
void startAnimation();
Ui::Form m_ui;
QGraphicsScene m_scene;
PixmapItem *m_item;

View File

@ -45,13 +45,13 @@
#include <QIODevice>
#include <QDataStream>
class Frame
class Frame
{
public:
Frame() {
}
int nodeCount() const
int nodeCount() const
{
return m_nodePositions.size();
}
@ -70,7 +70,7 @@ public:
{
m_nodePositions[idx] = pos;
}
private:
QVector<QPointF> m_nodePositions;
};
@ -81,7 +81,7 @@ Animation::Animation()
m_frames.append(new Frame);
}
Animation::~Animation()
Animation::~Animation()
{
qDeleteAll(m_frames);
}
@ -89,10 +89,10 @@ Animation::~Animation()
void Animation::setTotalFrames(int totalFrames)
{
while (m_frames.size() < totalFrames)
m_frames.append(new Frame);
m_frames.append(new Frame);
while (totalFrames < m_frames.size())
delete m_frames.takeLast();
delete m_frames.takeLast();
}
int Animation::totalFrames() const
@ -165,15 +165,15 @@ void Animation::load(QIODevice *device)
QDataStream stream(device);
stream >> m_name;
int frameCount;
stream >> frameCount;
for (int i=0; i<frameCount; ++i) {
int nodeCount;
stream >> nodeCount;
Frame *frame = new Frame;
frame->setNodeCount(nodeCount);

View File

@ -65,7 +65,7 @@ public:
if (QSignalTransition::eventTest(e)) {
QVariant key = static_cast<QStateMachine::SignalEvent*>(e)->arguments().at(0);
return (key.toInt() == int(m_key));
}
}
return false;
}
@ -100,7 +100,7 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
const int stickManNodeCount = m_stickMan->nodeCount();
for (int i=0; i<stickManNodeCount; ++i) {
QPropertyAnimation *pa = new QPropertyAnimation(m_stickMan->node(i), "pos");
m_animationGroup->addAnimation(pa);
m_animationGroup->addAnimation(pa);
}
// Set up initial state graph
@ -111,14 +111,14 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
m_alive = new QState(m_machine);
m_alive->setObjectName("alive");
// Make it blink when lightning strikes before entering dead animation
QState *lightningBlink = new QState(m_machine);
QState *lightningBlink = new QState(m_machine);
lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", QColor(Qt::white));
lightningBlink->assignProperty(m_stickMan, "penColor", QColor(Qt::black));
lightningBlink->assignProperty(m_stickMan, "fillColor", QColor(Qt::white));
lightningBlink->assignProperty(m_stickMan, "isDead", true);
//! [5]
QTimer *timer = new QTimer(lightningBlink);
timer->setSingleShot(true);
@ -126,13 +126,13 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
QObject::connect(lightningBlink, SIGNAL(entered()), timer, SLOT(start()));
QObject::connect(lightningBlink, SIGNAL(exited()), timer, SLOT(stop()));
//! [5]
m_dead = new QState(m_machine);
m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", QColor(Qt::black));
m_dead->assignProperty(m_stickMan, "penColor", QColor(Qt::white));
m_dead->assignProperty(m_stickMan, "fillColor", QColor(Qt::black));
m_dead->setObjectName("dead");
// Idle state (sets no properties)
m_idle = new QState(m_alive);
m_idle->setObjectName("idle");
@ -172,7 +172,7 @@ void LifeCycle::addActivity(const QString &fileName, Qt::Key key, QObject *sende
QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName)
{
QState *topLevel = new QState(parentState);
Animation animation;
{
QFile file(animationFileName);
@ -186,7 +186,7 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa
animation.setCurrentFrame(i);
//! [1]
QState *frameState = new QState(topLevel);
QState *frameState = new QState(topLevel);
const int nodeCount = animation.nodeCount();
for (int j=0; j<nodeCount; ++j)
frameState->assignProperty(m_stickMan->node(j), "pos", animation.nodePos(j));
@ -199,7 +199,7 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa
//! [2]
previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), frameState);
//! [2]
previousState = frameState;
}

View File

@ -62,7 +62,7 @@ QRectF Node::boundingRect() const
}
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
{
painter->setPen(Qt::white);
painter->drawEllipse(QPointF(0.0, 0.0), 5.0, 5.0);
}
@ -83,7 +83,7 @@ void Node::mousePressEvent(QGraphicsSceneMouseEvent *)
void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (m_dragging)
setPos(mapToParent(event->pos()));
setPos(mapToParent(event->pos()));
}
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *)

View File

@ -62,7 +62,7 @@ public:
virtual QRectF boundingRect() const;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
int nodeCount() const;
int nodeCount() const;
Node *node(int idx) const;
void setDrawSticks(bool on);
@ -90,7 +90,7 @@ private:
Node *m_nodes[NodeCount];
qreal m_perfectBoneLengths[BoneCount];
uint m_sticks : 1;
uint m_isDead : 1;
uint m_reserved : 30;

View File

@ -124,7 +124,7 @@ class OutputFilesPage : public QWizardPage
{
Q_OBJECT
public:
public:
OutputFilesPage(QWidget *parent = 0);
protected:

View File

@ -48,7 +48,7 @@
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(classwizard);
QApplication app(argc, argv);
#ifndef QT_NO_TRANSLATION

View File

@ -91,7 +91,7 @@ Dialog::Dialog()
//! [Dialog constructor part5]
connect(button, SIGNAL(clicked()),
qApp, SLOT(closeAllWindows()));
connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
connect(QApplication::desktop(), SIGNAL(workAreaResized(int)),
this, SLOT(desktopResized(int)));
}
//! [Dialog constructor part5]

View File

@ -36,7 +36,7 @@
\image addressbook-tutorial-screenshot.png
Ce tutoriel va nous amener à découvrir quelques technologies fondamentales fournies
Ce tutoriel va nous amener à découvrir quelques technologies fondamentales fournies
par Qt, tel que:
\list
@ -124,7 +124,7 @@
réutilisé dans d'autres projets
\endlist
Comme Qt ne fournit pas de widget standard pour un carnet d'adresses, nous
Comme Qt ne fournit pas de widget standard pour un carnet d'adresses, nous
partirons d'une classe de widget Qt standard et y ajouterons des fonctionnalités.
La classe \c AddressBook crée dans ce tutoriel peut être réutilisée si on a besoin d'un
widget carnet d'adresses basique.
@ -148,12 +148,12 @@
dans \c nameLine et \c addressText sont nécessaires à de nombreuses méthodes
du carnet d'adresses.
Il n'est pas nécessaire de déclarer les objets QLabel que nous allons utiliser
Il n'est pas nécessaire de déclarer les objets QLabel que nous allons utiliser
puisque nous n'aurons pas besoin d'y faire référence après leur création.
La façon dont Qt gère la parenté des objets est traitée dans la section suivante.
La macro Q_OBJECT implémente des fonctionnalités parmi les plus avancées de Qt.
Pour le moment, il est bon de voir la macro Q_OBJECT comme un raccourci nous
Pour le moment, il est bon de voir la macro Q_OBJECT comme un raccourci nous
permettant d'utiliser les méthodes \l{QObject::}{tr()} et \l{QObject::}{connect()}.
Nous en avons maintenant terminé avec le fichier \c addressbook.h et allons
@ -295,13 +295,13 @@
Le bouton \c addButton est affiché en invoquant la méthode \l{QPushButton::show()}
{show()}, tandis que \c submitButton et \c cancelButton sont cachés en invoquant
\l{QPushButton::hide()}{hide()}. Ces deux boutons ne seront affichés que lorsque
\l{QPushButton::hide()}{hide()}. Ces deux boutons ne seront affichés que lorsque
l'utilisateur cliquera sur "Add", et ceci est géré par la méthode \c addContact()
décrite plus loin.
\snippet tutorials/addressbook/part2/addressbook.cpp connecting signals and slots
Nous connectons le signal \l{QPushButton::clicked()}{clicked()} de chaque bouton
Nous connectons le signal \l{QPushButton::clicked()}{clicked()} de chaque bouton
au slot qui gèrera l'action.
L'image ci-dessous illustre ceci:
@ -379,8 +379,8 @@
\snippet tutorials/addressbook/part2/addressbook.cpp cancel
L'idée générale pour augmenter la flexibilité lors de l'ajout d'un
contact est de donner la possiblité de cliquer sur "Add"
L'idée générale pour augmenter la flexibilité lors de l'ajout d'un
contact est de donner la possiblité de cliquer sur "Add"
ou "Cancel" à n'importe quel moment.
L'organigramme ci-dessous reprend l'ensemble des interactions dévelopées
jusqu'ici:
@ -458,15 +458,15 @@
\c mainLayout.
\image addressbook-tutorial-part3-labeled-layout.png
Dans notre méthode \c addContact(), nous avons desactivé ces boutons
pour être sûr que l'utilisateur n'utilise pas la navigation lors de
Dans notre méthode \c addContact(), nous avons desactivé ces boutons
pour être sûr que l'utilisateur n'utilise pas la navigation lors de
l'ajout d'un contact.
\snippet tutorials/addressbook/part3/addressbook.cpp disabling navigation
Dans notre méthode \c submitContact(), nous activons les boutons de
navigation, \c nextButton et \c previousButton, en fonction de la
taille de \c contacts. Commen mentionné plus tôt, la navigation n'est
taille de \c contacts. Commen mentionné plus tôt, la navigation n'est
activée que si il y a plus d'un contact dans le carnet d'adresses.
Les lignes suivantes montrent comment faire cela:
@ -475,13 +475,13 @@
Nous incluons aussi ces lignes de code dans le bouton \c cancel().
Souvenez vous que nous voulons émuler une liste-liée ciruculaire à
l'aide de l'objet QMap, \c contacts. Pour faire cela, nous obtenons un itérateur
l'aide de l'objet QMap, \c contacts. Pour faire cela, nous obtenons un itérateur
sur \c contact dans la méthode \c next(), et ensuite:
\list
\li Si l'itérateur n'est pas à la fin de \c contacts, nous l'incrémentons
\li Si l'itérateur est à la fin de \c contacts, nous changeons sa position
jusqu'au début de \c contacts. Cela donne l'illusion que notre QMap
jusqu'au début de \c contacts. Cela donne l'illusion que notre QMap
fonctionne comme une liste circulaire.
\endlist
@ -490,7 +490,7 @@
Une fois que nous avons itéré jusqu'à l'objet recherché dans \c contacts,
nous affichons son contenu sur \c nameLine et \c addressText.
De la même façon, pour la méthode \c previous(), nous obtenons un
De la même façon, pour la méthode \c previous(), nous obtenons un
itérateur sur \c contacts et ensuite:
\list
@ -522,7 +522,7 @@
\image addressbook-tutorial-screenshot.png
Nous avons maintenant un carnet d'adresses qui ne se contente pas de
lister des contacts de façon ordonnée, mais permet également la
lister des contacts de façon ordonnée, mais permet également la
navigation. Il serait pratique d'inclure des fonctions telles qu'éditer et
supprimer, afin que les détails associés à un contact puissent être
modifiés lorsque c'est nécessaire. Cependant, cela requiert une légère
@ -563,7 +563,7 @@
\dots
\snippet tutorials/addressbook/part4/addressbook.h mode declaration
Enfin, on déclare \c currentMode pour garder une trace du mode
Enfin, on déclare \c currentMode pour garder une trace du mode
actuellement utilisé.
\section1 Implémentation de la classe AddressBook
@ -637,7 +637,7 @@
avant de tester sa valeur.
Chacun des boutons est ensuite activé ou désactivé, en fonction du mode.
Le code source pour les cas \c AddingMode et \c EditingMode est visible
Le code source pour les cas \c AddingMode et \c EditingMode est visible
ci-dessous:
\snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 1
@ -840,7 +840,7 @@
\section1 Définition de la classe AddressBook
On déclare deux slots publics, \c saveToFile() et \c loadFromFile(),
On déclare deux slots publics, \c saveToFile() et \c loadFromFile(),
ainsi que deux objets QPushButton, \c loadButton et \c saveButton.
\snippet tutorials/addressbook/part6/addressbook.h save and load functions declaration
@ -863,11 +863,11 @@
\snippet tutorials/addressbook/part6/addressbook.cpp tooltip 2
Bien qu'on ne cite pas le code correspondant ici, nous ajoutons ces deux boutons au
layout de droite, \c button1Layout, comme pour les fonctionnalités précédentes, et
layout de droite, \c button1Layout, comme pour les fonctionnalités précédentes, et
nous connectons leurs signaux
\l{QPushButton::clicked()}{clicked()} à leurs slots respectifs.
Pour la sauvegarde, on commence par récupérer le nom de fichier
Pour la sauvegarde, on commence par récupérer le nom de fichier
\c fileName, en utilisant QFileDialog::getSaveFileName(). C'est une
méthode pratique fournie par QFileDialog, qui ouvre une boîte de
dialogue modale et permet à l'utilisateur d'entrer un nom de fichier ou
@ -966,7 +966,7 @@
\section1 Définition de la classe AddressBook
Nous ajoutons un objet QPushButton, \c exportButton, et un slot
public correspondant, \c exportAsVCard(), à notre classe \c AddressBook
public correspondant, \c exportAsVCard(), à notre classe \c AddressBook
dans le fichier \c addressbook.h.
\snippet tutorials/addressbook/part7/addressbook.h exportAsVCard() declaration
@ -1001,7 +1001,7 @@
cela échoue, nous affichons un QMessageBox pour informer l'utilisateur
à propos de l'origine du problème et nous quittons la méthode. Sinon, nous passons le
fichier comme paramètre pour créer un objet QTextStream, \c out. De la même façon que
QDataStream, la classe QTextStream fournit les fonctionnalités pour
QDataStream, la classe QTextStream fournit les fonctionnalités pour
lire et écrire des fichiers de texte. Grâce à celà, le fichier \c{.vcf}
généré pourra être ouvert et édité à l'aide d'un simple éditeur de texte.
@ -1014,7 +1014,7 @@
à un nom de famille défini ou non. Si oui, nous utilions les détails de
\c nameList pour remplir le champ, dans le cas contraire on écrit uniquement le contenu
de \c firstName.
\snippet tutorials/addressbook/part7/addressbook.cpp export function part3
Nous continuons en écrivant l'adresse du contact. Les points-virgules
@ -1026,7 +1026,7 @@
\snippet tutorials/addressbook/part7/addressbook.cpp export function part4
À la fin de la méthode, un QMessageBox est affiché pour informer l'utilisateur
que la vCard a été exportée avec succès.
que la vCard a été exportée avec succès.
\e{vCard est une marque déposée de \l{http://www.imc.org}
{Internet Mail Consortium}}.

View File

@ -73,7 +73,7 @@
have worked through this tutorial, we recommend reading the
\l{mainwindows/application}{Application} example, which presents a
small GUI application, with menus, toolbars, a status bar, and so
on.
on.
*/
/*!
@ -199,7 +199,7 @@
Notice that \c addressLabel is positioned using Qt::AlignTop as an
additional argument. This is to make sure it is not vertically centered in
cell (1,0). For a basic overview on Qt Layouts, refer to the
cell (1,0). For a basic overview on Qt Layouts, refer to the
\l{Layout Management} documentation.
In order to install the layout object onto the widget, we have to invoke
@ -431,7 +431,7 @@
\snippet tutorials/addressbook/part3/addressbook.cpp connecting navigation signals
The image below is the expected graphical user interface.
The image below is the expected graphical user interface.
\image addressbook-tutorial-part3-screenshot.png

View File

@ -273,7 +273,7 @@
\snippet itemviews/addressbook/addresswidget.cpp 4a
Next we extract data from the row the user intends to
Next we extract data from the row the user intends to
edit. This data is displayed in an instance of \c AddDialog
with a different window title. The \c table is only
updated if changes have been made to data in \c aDialog.

View File

@ -60,7 +60,7 @@
We will now move on to the definitions and implementations of \c
CodeEditor and \c LineNumberArea. Let's start with the \c
LineNumberArea class.
LineNumberArea class.
\section1 The LineNumberArea Class
@ -130,7 +130,7 @@
\snippet widgets/codeeditor/codeeditor.cpp resizeEvent
When the size of the editor changes, we also need to resize the
line number area.
line number area.
\snippet widgets/codeeditor/codeeditor.cpp cursorPositionChanged
@ -155,7 +155,7 @@
The \c lineNumberAreaPaintEvent() is called from \c LineNumberArea
whenever it receives a paint event. We start off by painting the
widget's background.
widget's background.
\snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_1
@ -163,11 +163,11 @@
numbers in the extra area for each line. Notice that in a plain
text edit each line will consist of one QTextBlock; though, if
line wrapping is enabled, a line may span several rows in the text
edit's viewport.
edit's viewport.
We get the top and bottom y-coordinate of the first text block,
and adjust these values by the height of the current text block in
each iteration in the loop.
each iteration in the loop.
\snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_2
@ -183,7 +183,7 @@
In addition to line numbers, you can add more to the extra area,
for instance, break points.
QSyntaxHighlighter gives the possibility to add user data to each
text block with
\l{QSyntaxHighlighter::}{setCurrentBlockUserData()}. This can be

View File

@ -78,7 +78,7 @@
After the new factory has been set, all standard item delegates
will use it (i.e, also delegates that were created before the new
default factory was set).
default factory was set).
The \c createGUI() function sets up the table and fills it
with data.
@ -135,17 +135,17 @@
\list
\li If the editor widget has no user property defined, the delegate
asks the factory for the property name, which it in turn
asks the item editor creator for. In this case, you can use
the QItemEditorCreator class, which takes the property
name to use for editing as a constructor argument.
asks the factory for the property name, which it in turn
asks the item editor creator for. In this case, you can use
the QItemEditorCreator class, which takes the property
name to use for editing as a constructor argument.
\li If the editor requires other constructors or other
initialization than provided by QItemEditorCreatorBase, you
must reimplement
QItemEditorCreatorBase::createWidget().
initialization than provided by QItemEditorCreatorBase, you
must reimplement
QItemEditorCreatorBase::createWidget().
\li You could also subclass QItemEditorFactory if you only want
to provide editors for certain kinds of data or use another
method of creating the editors than using creator bases.
to provide editors for certain kinds of data or use another
method of creating the editors than using creator bases.
\endlist
In this example, we use a standard QVariant data type. You can

View File

@ -50,7 +50,7 @@
In this example we show how to create such custom graphics
scenes and items by implementing classes that inherit
QGraphicsScene and QGraphicsItem.
QGraphicsScene and QGraphicsItem.
In particular we show how to:
@ -65,21 +65,21 @@
The example consists of the following classes:
\list
\li \c MainWindow creates the widgets and display
them in a QMainWindow. It also manages the interaction
between the widgets and the graphics scene, view and
items.
them in a QMainWindow. It also manages the interaction
between the widgets and the graphics scene, view and
items.
\li \c DiagramItem inherits QGraphicsPolygonItem and
represents a flowchart shape.
represents a flowchart shape.
\li \c TextDiagramItem inherits QGraphicsTextItem and
represents text items in the diagram. The class adds
support for moving the item with the mouse, which is not
supported by QGraphicsTextItem.
represents text items in the diagram. The class adds
support for moving the item with the mouse, which is not
supported by QGraphicsTextItem.
\li \c Arrow inherits QGraphicsLineItem and is an arrow
that connect two DiagramItems.
that connect two DiagramItems.
\li \c DiagramScene inherits QGraphicsDiagramScene and
provides support for \c DiagramItem, \c Arrow and
\c DiagramTextItem (In addition to the support already
handled by QGraphicsScene).
provides support for \c DiagramItem, \c Arrow and
\c DiagramTextItem (In addition to the support already
handled by QGraphicsScene).
\endlist
\section1 MainWindow Class Definition
@ -88,7 +88,7 @@
The \c MainWindow class creates and lays out the widgets in a
QMainWindow. The class forwards input from the widgets to the
DiagramScene. It also updates its widgets when the diagram
DiagramScene. It also updates its widgets when the diagram
scene's text item changes, or a diagram item or a diagram text item
is inserted into the scene.
@ -104,8 +104,8 @@
\snippet graphicsview/diagramscene/mainwindow.cpp 0
In the constructor we call methods to create the widgets and
layouts of the example before we create the diagram scene.
The toolbars must be created after the scene as they connect
layouts of the example before we create the diagram scene.
The toolbars must be created after the scene as they connect
to its signals. We then lay the widgets out in the window.
We connect to the \c itemInserted() and \c textInserted() slots of
@ -115,20 +115,20 @@
update the widgets that display font properties if the item
selected is a \c DiagramTextItem.
The \c createToolBox() function creates and lays out the widgets
The \c createToolBox() function creates and lays out the widgets
of the \c toolBox QToolBox. We will not examine it with a
high level of detail as it does not deal with graphics framework
high level of detail as it does not deal with graphics framework
specific functionality. Here is its implementation:
\snippet graphicsview/diagramscene/mainwindow.cpp 21
This part of the function sets up the tabbed widget item that
contains the flowchart shapes. An exclusive QButtonGroup always
contains the flowchart shapes. An exclusive QButtonGroup always
keeps one button checked; we want the group to allow all buttons
to be unchecked.
We still use a button group since we can associate user
data, which we use to store the diagram type, with each button.
The \c createCellWidget() function sets up the buttons in the
data, which we use to store the diagram type, with each button.
The \c createCellWidget() function sets up the buttons in the
tabbed widget item and is examined later.
The buttons of the background tabbed widget item is set up in the
@ -137,7 +137,7 @@
\snippet graphicsview/diagramscene/mainwindow.cpp 22
We set the preferred size of the toolbox as its maximum. This
way, more space is given to the graphics view.
way, more space is given to the graphics view.
Here is the \c createActions() function:
@ -202,7 +202,7 @@
with this function is used in the tool box.
Here is the \c createColorMenu() function:
\snippet graphicsview/diagramscene/mainwindow.cpp 30
This function creates a color menu that is used as the
@ -224,7 +224,7 @@
\snippet graphicsview/diagramscene/mainwindow.cpp 32
This function creates an icon with a filled rectangle in the
This function creates an icon with a filled rectangle in the
color of \a color. It is used for creating icons for the color
menus in the \c fillColorToolButton, \c fontColorToolButton, and
\c lineColorToolButton.
@ -240,8 +240,8 @@
with.
When one of the buttons in the background tabbed widget item is
clicked we change the brush; we find out which button it is by
checking its text.
clicked we change the brush; we find out which button it is by
checking its text.
Here is the implementation of \c buttonGroupClicked():
@ -255,37 +255,37 @@
checked at a time.
\c QButtonGroup assigns an id to each button. We have set the id
of each button to the diagram type, as given by DiagramItem::DiagramType
that will be inserted into the scene when it is clicked. We can
then use the button id when we set the diagram type with
of each button to the diagram type, as given by DiagramItem::DiagramType
that will be inserted into the scene when it is clicked. We can
then use the button id when we set the diagram type with
\c setItemType(). In the case of text we assigned an id that has a
value that is not in the DiagramType enum.
Here is the implementation of \c deleteItem():
\snippet graphicsview/diagramscene/mainwindow.cpp 3
This slot deletes the selected item, if any, from the scene. It
deletes the arrows first in order to avoid to delete them twice. If
the item to be deleted is a \c DiagramItem, we also need to delete
arrows connected to it; we don't want arrows in the scene that
aren't connected to items in both ends.
This is the implementation of pointerGroupClicked():
\snippet graphicsview/diagramscene/mainwindow.cpp 4
The \c pointerTypeGroup decides whether the scene is in ItemMove
or InsertLine mode. This button group is exclusive, i.e., only
or InsertLine mode. This button group is exclusive, i.e., only
one button is checked at any time. As with the \c buttonGroup above
we have assigned an id to the buttons that matches values of the
DiagramScene::Mode enum, so that we can use the id to set the
correct mode.
Here is the \c bringToFront() slot:
\snippet graphicsview/diagramscene/mainwindow.cpp 5
Several items may collide, i.e., overlap, with each other in
the scene. This slot is called when the user requests that an
item should be placed on top of the items it collides with.
@ -296,169 +296,169 @@
lower values. When we bring an item to the front we can loop
through the items it collides with and set a z-value that is
higher than all of them.
Here is the \c sendToBack() slot:
\snippet graphicsview/diagramscene/mainwindow.cpp 6
This slot works in the same way as \c bringToFront() described
above, but sets a z-value that is lower than items the item that
should be send to the back collides with.
This is the implementation of \c itemInserted():
\snippet graphicsview/diagramscene/mainwindow.cpp 7
This slot is called from the \c DiagramScene when an item has been
added to the scene. We set the mode of the scene back to the mode
before the item was inserted, which is ItemMove or InsertText
depending on which button is checked in the \c pointerTypeGroup.
depending on which button is checked in the \c pointerTypeGroup.
We must also uncheck the button in the in the \c buttonGroup.
Here is the implementation of \c textInserted():
\snippet graphicsview/diagramscene/mainwindow.cpp 8
We simply set the mode of the scene back to the mode it had before
the text was inserted.
Here is the \c currentFontChanged() slot:
\snippet graphicsview/diagramscene/mainwindow.cpp 9
When the user requests a font change, by using one of the
widgets in the \c fontToolBar, we create a new QFont object and
set its properties to match the state of the widgets. This is done
in \c handleFontChange(), so we simply call that slot.
Here is the \c fontSizeChanged() slot:
\snippet graphicsview/diagramscene/mainwindow.cpp 10
When the user requests a font change, by using one of the
widgets in the \c fontToolBar, we create a new QFont object and
set its properties to match the state of the widgets. This is done
in \c handleFontChange(), so we simply call that slot.
Here is the implementation of \c sceneScaleChanged():
\snippet graphicsview/diagramscene/mainwindow.cpp 11
The user can increase or decrease the scale, with the \c
sceneScaleCombo, the scene is drawn in.
It is not the scene itself that changes its scale, but only the
view.
view.
Here is the \c textColorChanged() slot:
\snippet graphicsview/diagramscene/mainwindow.cpp 12
This slot is called when an item in the drop-down menu of the \c
fontColorToolButton is pressed. We need to change the icon on
fontColorToolButton is pressed. We need to change the icon on
the button to the color of the selected QAction. We keep a pointer
to the selected action in \c textAction. It is in \c
textButtonTriggered() we change the text color to the color of \c
textAction, so we call that slot.
Here is the \c itemColorChanged() implementation:
\snippet graphicsview/diagramscene/mainwindow.cpp 13
This slot handles requests for changing the color of \c
DiagramItems in the same manner as \c textColorChanged() does for
\c DiagramTextItems.
Here is the implementation of \c lineColorChanged():
\snippet graphicsview/diagramscene/mainwindow.cpp 14
This slot handles requests for changing the color of \c Arrows in
the same manner that \c textColorChanged() does it for \c
DiagramTextItems.
Here is the \c textButtonTriggered() slot:
\snippet graphicsview/diagramscene/mainwindow.cpp 15
\c textAction points to the QAction of the currently selected menu item
in the \c fontColorToolButton's color drop-down menu. We have set
the data of the action to the QColor the action represents, so we
can simply fetch this when we set the color of text with \c
setTextColor().
Here is the \c fillButtonTriggered() slot:
\snippet graphicsview/diagramscene/mainwindow.cpp 16
\c fillAction points to the selected menu item in the drop-down
menu of \c fillColorToolButton(). We can therefore use the data of
this action when we set the item color with \c setItemColor().
Here is the \c lineButtonTriggered() slot:
\snippet graphicsview/diagramscene/mainwindow.cpp 17
\c lineAction point to the selected item in the drop-down menu of
\c lineColorToolButton. We use its data when we set the arrow
\c lineColorToolButton. We use its data when we set the arrow
color with \c setLineColor().
Here is the \c handleFontChange() function:
\snippet graphicsview/diagramscene/mainwindow.cpp 18
\c handleFontChange() is called when any of the widgets that show
font properties changes. We create a new QFont object and set its
properties based on the widgets. We then call the \c setFont()
function of \c DiagramScene; it is the scene that set the font of
the \c DiagramTextItems it manages.
Here is the \c itemSelected() slot:
\snippet graphicsview/diagramscene/mainwindow.cpp 19
This slot is called when an item in the \c DiagramScene is
selected. In the case of this example it is only text items that
emit signals when they are selected, so we do not need to check
what kind of graphics \a item is.
We set the state of the widgets to match the properties of the
font of the selected text item.
This is the \c about() slot:
\snippet graphicsview/diagramscene/mainwindow.cpp 20
This slot displays an about box for the example when the user
selects the about menu item from the help menu.
\section1 DiagramScene Class Definition
The \c DiagramScene class inherits QGraphicsScene and adds
functionality to handle \c DiagramItems, \c Arrows, and \c
DiagramTextItems in addition to the items handled by its super
class.
\snippet graphicsview/diagramscene/diagramscene.h 0
In the \c DiagramScene a mouse click can give three different
actions: the item under the mouse can be moved, an item may be
inserted, or an arrow may be connected between to diagram items.
Which action a mouse click has depends on the mode, given by the
Mode enum, the scene is in. The mode is set with the \c setMode()
function.
The scene also sets the color of its items and the font of its
text items. The colors and font used by the scene can be set with
the \c setLineColor(), \c setTextColor(), \c setItemColor() and \c
setFont() functions. The type of \c DiagramItem, given by the
DiagramItem::DiagramType function, to be created when an item is
inserted is set with the \c setItemType() slot.
The \c MainWindow and \c DiagramScene share responsibility for
the examples functionality. \c MainWindow handles the following
tasks: the deletion of items, text, and arrows; moving diagram
items to the back and front; and setting the scale of the scene.
items to the back and front; and setting the scale of the scene.
\section1 DiagramScene Class Implementation
@ -492,12 +492,12 @@
\snippet graphicsview/diagramscene/diagramscene.cpp 3
This function sets the color the scene will use when creating
This function sets the color the scene will use when creating
\c DiagramItems. It also changes the color of a selected \c
DiagramItem.
This is the implementation of \c setFont():
\snippet graphicsview/diagramscene/diagramscene.cpp 4
Set the font to use for new and selected, if a text item is
@ -511,15 +511,15 @@
connected to this slot. We remove the item if it has no text.
If not, we would leak memory and confuse the user as the items
will be edited when pressed on by the mouse.
The \c mousePressEvent() function handles mouse press event's
different depending on which mode the \c DiagramScene is in. We
examine its implementation for each mode:
\snippet graphicsview/diagramscene/diagramscene.cpp 6
We simply create a new \c DiagramItem and add it to the scene at
the position the mouse was pressed. Note that the origin of its
the position the mouse was pressed. Note that the origin of its
local coordinate system will be under the mouse pointer position.
\snippet graphicsview/diagramscene/diagramscene.cpp 7
@ -534,7 +534,7 @@
line.
\snippet graphicsview/diagramscene/diagramscene.cpp 8
The \c DiagramTextItem is editable when the
Qt::TextEditorInteraction flag is set, else it is movable by the
mouse. We always want the text to be drawn on top of the other
@ -547,12 +547,12 @@
can then call the QGraphicsScene implementation, which
handles movement of items with the mouse. We make this call even
if we are in another mode making it possible to add an item and
then keep the mouse button pressed down and start moving
then keep the mouse button pressed down and start moving
the item. In the case of text items, this is not possible as they
do not propagate mouse events when they are editable.
This is the \c mouseMoveEvent() function:
\snippet graphicsview/diagramscene/diagramscene.cpp 10
We must draw the line if we are in InsertMode and the mouse button
@ -567,7 +567,7 @@
should be added to the scene:
\snippet graphicsview/diagramscene/diagramscene.cpp 11
First we need to get the items (if any) under the line's start
and end points. The line itself is the first item at these points,
so we remove it from the lists. As a precaution, we check if the
@ -603,7 +603,7 @@
DiagramScene. It inherits QGraphicsPolygonItem and has a polygon
for each shape. The enum DiagramType has a value for each of the
flowchart shapes.
The class has a list of the arrows that are connected to it.
This is necessary because only the item knows when it is being
moved (with the \c itemChanged() function) at which time the
@ -612,7 +612,7 @@
buttons in \c MainWindow, see \c createColorToolButtonIcon() in
\c MainWindow.
The Type enum is a unique identifier of the class. It is used by
The Type enum is a unique identifier of the class. It is used by
\c qgraphicsitem_cast(), which does dynamic casts of graphics
items. The UserType constant is the minimum value a custom
graphics item type can be.
@ -646,7 +646,7 @@
item.
Here is the \c addArrow() function:
\snippet graphicsview/diagramscene/diagramitem.cpp 3
This function simply adds the \a arrow to the items \c arrows list.
@ -695,7 +695,7 @@
possible to alter the mouse behavior of QGraphicsTextItem.
\section1 DiagramTextItem Implementation
We start with the constructor:
\snippet graphicsview/diagramscene/diagramtextitem.cpp 0
@ -717,7 +717,7 @@
\c DiagramScene uses the signal emitted when the text item looses
focus to remove the item if it is empty, i.e., it contains no
text.
text.
This is the implementation of \c mouseDoubleClickEvent():
@ -740,7 +740,7 @@
The item's color can be set with \c setColor().
\c boundingRect() and \c shape() are reimplemented
\c boundingRect() and \c shape() are reimplemented
from QGraphicsLineItem and are used by the scene
to check for collisions and selections.
@ -769,7 +769,7 @@
We need to reimplement this function because the arrow is
larger than the bounding rectangle of the QGraphicsLineItem. The
graphics scene uses the bounding rectangle to know which regions
of the scene to update.
of the scene to update.
Here is the \c shape() function:
@ -779,14 +779,14 @@
shape of the item. The QGraphicsLineItem::shape() returns a path
with a line drawn with the current pen, so we only need to add
the arrow head. This function is used to check for collisions and
selections with the mouse.
selections with the mouse.
Here is the \c updatePosition() slot:
\snippet graphicsview/diagramscene/arrow.cpp 3
This slot updates the arrow by setting the start and end
points of its line to the center of the items it connects.
points of its line to the center of the items it connects.
Here is the \c paint() function:
@ -809,7 +809,7 @@
one of the lines of the polygon. Note that the points in the
polygon are relative to the local coordinate system of the item.
We must therefore add the position of the end item to make the
coordinates relative to the scene.
coordinates relative to the scene.
\snippet graphicsview/diagramscene/arrow.cpp 6

View File

@ -133,7 +133,7 @@
that the entire name and address insertion is treated as a single
operation by the QTextEdit, so a single undo will revert all the
insertions.
\snippet mainwindows/dockwidgets/mainwindow.cpp 7
This function works in a similar way to \c insertCustomer(). First
@ -141,7 +141,7 @@
replace it with the standard paragraph that the user clicked. Again
we use a \c beginEditBlock() ... \c endEditBlock() pair so that the
insertion can be undone as a single operation.
\snippet mainwindows/dockwidgets/mainwindow.cpp 3
Qt's QTextDocument class makes printing documents easy. We simply

View File

@ -31,7 +31,7 @@
\brief The Easing Curves example shows how to use easing curves to
control the speed of an animation.
\image easing-example.png
*/

View File

@ -46,7 +46,7 @@
System}{meta-object system}. The plugin \l{How to Create Qt
Plugins}{overview document} gives a high-level introduction to
plugins.
We have implemented a plugin, the \c EchoPlugin, which implements
the \c EchoInterface. The interface consists of \c echo(), which
takes a QString as argument. The \c EchoPlugin returns the string
@ -68,8 +68,8 @@
\snippet tools/echoplugin/echowindow/echowindow.h 0
We load the plugin in \c loadPlugin() and cast it to \c
EchoInterface. When the user clicks the \c button we take the
text in \c lineEdit and call the interface's \c echo() with it.
EchoInterface. When the user clicks the \c button we take the
text in \c lineEdit and call the interface's \c echo() with it.
\section1 EchoWindow Class Implementation
@ -136,15 +136,15 @@
System}{Qt's meta object system} aware of the interface. We do
this so that it will be possible to identify plugins that
implements the interface at run-time. The second argument is a
string that must identify the interface in a unique way.
string that must identify the interface in a unique way.
\section1 EchoPlugin Class Definition
We inherit both QObject and \c EchoInterface to make this class a
plugin. The Q_INTERFACES macro tells Qt which interfaces the class
implements. In our case we only implement the \c EchoInterface.
If a class implements more than one interface, they are given as
implements. In our case we only implement the \c EchoInterface.
If a class implements more than one interface, they are given as
a comma separated list. The Q_PLUGIN_METADATA macro is included next
to the Q_OBJECT macro. It contains the plugins IID and a filename
pointing to a json file containing the metadata for the plugin.
@ -158,7 +158,7 @@
\snippet tools/echoplugin/plugin/echoplugin.cpp 0
We simply return the functions parameter.
We simply return the functions parameter.
\section1 The \c main() function
@ -169,7 +169,7 @@
\section1 The Profiles
When creating plugins the profiles need to be adjusted.
We show here what changes need to be done.
We show here what changes need to be done.
The profile in the echoplugin directory uses the \c subdirs
template and simply includes includes to directories in which
@ -196,7 +196,7 @@
You can find an overview of the macros needed to create plugins
\l{Macros for Defining Plugins}{here}.
We give an example of a plugin that extend Qt in the \l{Style
Plugin Example}{style plugin} example. The \l{Plug & Paint
Example}{plug and paint} example shows how to create static

View File

@ -62,7 +62,7 @@
\l{QAbstractItemModel::}{fetchMore()} and
\l{QAbstractItemModel::}{canFetchMore()} from QAbstractItemModel.
These functions are called by the item view when it needs more
items.
items.
The \c setDirPath() function sets the directory the model will
work on. We emit \c numberPopulated() each time we add a batch of

View File

@ -35,27 +35,27 @@
\image flowlayout-example.png Screenshot of the Flow Layout example
The items are first laid out horizontally and then vertically when each line
in the layout runs out of space.
in the layout runs out of space.
The Flowlayout class mainly uses QLayout and QWidgetItem, while the
Window uses QWidget and QLabel. We will only document the definition
and implementation of \c FlowLayout below.
The Flowlayout class mainly uses QLayout and QWidgetItem, while the
Window uses QWidget and QLabel. We will only document the definition
and implementation of \c FlowLayout below.
\section1 FlowLayout Class Definition
The \c FlowLayout class inherits QLayout. It is a custom layout class
that arranges its child widgets horizontally and vertically.
The \c FlowLayout class inherits QLayout. It is a custom layout class
that arranges its child widgets horizontally and vertically.
\snippet layouts/flowlayout/flowlayout.h 0
We reimplement functions inherited from QLayout. These functions add items to
the layout and handle their orientation and geometry.
the layout and handle their orientation and geometry.
We also declare two private methods, \c doLayout() and \c smartSpacing().
\c doLayout() lays out the layout items, while the \c
smartSpacing() function calculates the spacing between them.
\section1 FlowLayout Class Implementation
\section1 FlowLayout Class Implementation
We start off by looking at the constructor:
@ -63,32 +63,32 @@
In the constructor we call \c setContentsMargins() to set the left, top,
right and bottom margin. By default, QLayout uses values provided by
the current style (see QStyle::PixelMetric).
the current style (see QStyle::PixelMetric).
\snippet layouts/flowlayout/flowlayout.cpp 2
In this example we reimplement \c addItem(), which is a pure virtual
function. When using \c addItem() the ownership of the layout items is
transferred to the layout, and it is therefore the layout's
responsibility to delete them.
In this example we reimplement \c addItem(), which is a pure virtual
function. When using \c addItem() the ownership of the layout items is
transferred to the layout, and it is therefore the layout's
responsibility to delete them.
\snippet layouts/flowlayout/flowlayout.cpp 3
\c addItem() is implemented to add items to the layout.
\c addItem() is implemented to add items to the layout.
\snippet layouts/flowlayout/flowlayout.cpp 4
We implement \c horizontalSpacing() and \c verticalSpacing() to get
hold of the spacing between the widgets inside the layout. If the value
is less than or equal to 0, this value will be used. If not,
hold of the spacing between the widgets inside the layout. If the value
is less than or equal to 0, this value will be used. If not,
\c smartSpacing() will be called to calculate the spacing.
\snippet layouts/flowlayout/flowlayout.cpp 5
We then implement \c count() to return the number of items in the
layout. To navigate the list of items we use \c itemAt() and
takeAt() to remove and return items from the list. If an item is
removed, the remaining items will be renumbered. All three
We then implement \c count() to return the number of items in the
layout. To navigate the list of items we use \c itemAt() and
takeAt() to remove and return items from the list. If an item is
removed, the remaining items will be renumbered. All three
functions are pure virtual functions from QLayout.
\snippet layouts/flowlayout/flowlayout.cpp 6
@ -103,7 +103,7 @@
dependency, and \c heightForWidth() passes the width on to \c doLayout() which
in turn uses the width as an argument for the layout rect, i.e., the bounds in
which the items are laid out. This rect does not include the layout margin().
\snippet layouts/flowlayout/flowlayout.cpp 8
\c setGeometry() is normally used to do the actual layout, i.e., calculate
@ -116,30 +116,30 @@
\snippet layouts/flowlayout/flowlayout.cpp 9
\c doLayout() handles the layout if \c horizontalSpacing() or \c
verticalSpacing() don't return the default value. It uses
\c getContentsMargins() to calculate the area available to the
layout items.
verticalSpacing() don't return the default value. It uses
\c getContentsMargins() to calculate the area available to the
layout items.
\snippet layouts/flowlayout/flowlayout.cpp 10
It then sets the proper amount of spacing for each widget in the
layout, based on the current style.
It then sets the proper amount of spacing for each widget in the
layout, based on the current style.
\snippet layouts/flowlayout/flowlayout.cpp 11
The position of each item in the layout is then calculated by
adding the items width and the line height to the initial x and y
coordinates. This in turn lets us find out whether the next item
will fit on the current line or if it must be moved down to the next.
We also find the height of the current line based on the widgets height.
The position of each item in the layout is then calculated by
adding the items width and the line height to the initial x and y
coordinates. This in turn lets us find out whether the next item
will fit on the current line or if it must be moved down to the next.
We also find the height of the current line based on the widgets height.
\snippet layouts/flowlayout/flowlayout.cpp 12
\c smartSpacing() is designed to get the default spacing for either
the top-level layouts or the sublayouts. The default spacing for
top-level layouts, when the parent is a QWidget, will be determined
by querying the style. The default spacing for sublayouts, when
the parent is a QLayout, will be determined by querying the spacing
of the parent layout.
\c smartSpacing() is designed to get the default spacing for either
the top-level layouts or the sublayouts. The default spacing for
top-level layouts, when the parent is a QWidget, will be determined
by querying the style. The default spacing for sublayouts, when
the parent is a QLayout, will be determined by querying the spacing
of the parent layout.
*/

View File

@ -30,7 +30,7 @@
\title Font Sampler Example
\ingroup examples-painting
\brief The Font Sampler example shows how to preview and print multi-page documents.
The Font Sampler example shows how to preview and print multi-page documents.
\image fontsampler-example.png

View File

@ -230,7 +230,7 @@
top-level corner of the drag pixmap, to be the point we calculated
above. This makes the process of dragging the label feel more natural
because the cursor always points to the same place on the label
during the drag operation.
during the drag operation.
We start the drag operation using QDrag's \l{QDrag::}{exec()} function,
requesting that the magnet is copied when the drag is completed.

View File

@ -25,7 +25,7 @@
**
****************************************************************************/
/*!
/*!
\example mainwindows/mdi
\title MDI Example
\ingroup examples-mainwindow

View File

@ -43,7 +43,7 @@
\li \c StateSwitcher inherits QState and can add
\c {StateSwitchTransition}s to other states.
When entered, it will randomly transition to one of these
states.
states.
\li \c StateSwitchTransition is a custom transition that
triggers on \c{StateSwitchEvent}s.
\li \c StateSwitchEvent is a QEvent that triggers \c{StateSwitchTransition}s.
@ -152,7 +152,7 @@
\c StateSwitcher is a state designed for a particular purpose and
will always be a top-level state. We use \c m_stateCount to keep
track of how many states we are managing, and \c m_lastIndex to
remember which state was the last state to which we transitioned.
remember which state was the last state to which we transitioned.
\snippet animation/moveblocks/main.cpp 11

View File

@ -216,7 +216,7 @@
This enables the items to be drawn without any gaps between them. Removing
the headers also prevents the user from adjusting the sizes of individual
rows and columns.
rows and columns.
We also set the minimum section size to 1 on the headers. If we
didn't, the headers would default to a larger size, preventing

View File

@ -25,7 +25,7 @@
**
****************************************************************************/
/*!
/*!
\example mainwindows/recentfiles
\title Recent Files Example
\ingroup examples-mainwindow

View File

@ -25,7 +25,7 @@
**
****************************************************************************/
/*!
/*!
\example tools/regexp
\title Regular Expressions Example
\ingroup examples-widgets-tools

View File

@ -151,7 +151,7 @@
When we enter \c quitState, we update the status bar of the
window.
\c QKeyEventTransition is a utility class that removes the hassle
of implementing transitions for \l{QKeyEvent}s. We simply need to
specify the key on which the transition should trigger and the
@ -161,7 +161,7 @@
The transition from \c inputState allows triggering the quit state
when the player types \c {q}.
\snippet statemachine/rogue/window.cpp 5
The machine is set up, so it's time to start it.

View File

@ -25,7 +25,7 @@
**
****************************************************************************/
/*!
/*!
\example mainwindows/sdi
\title SDI Example
\ingroup examples-mainwindow

View File

@ -25,7 +25,7 @@
**
****************************************************************************/
/*!
/*!
\example tools/settingseditor
\title Settings Editor Example
\ingroup examples-widgets-tools

View File

@ -61,7 +61,7 @@
The constructor of the \c Window class can be explained in three parts.
In the first part, we set up the widgets used for the user interface:
\snippet itemviews/simplewidgetmapper/window.cpp Set up widgets
We also set up the buddy relationships between various labels and the

View File

@ -25,7 +25,7 @@
**
****************************************************************************/
/*!
/*!
\example widgets/spinboxes
\title Spin Boxes Example
\ingroup examples-widgets

View File

@ -25,7 +25,7 @@
**
****************************************************************************/
/*!
/*!
\example dialogs/standarddialogs
\title Standard Dialogs Example
\ingroup examples-dialogs

View File

@ -257,7 +257,7 @@
\l{QAbstractItemView::editTriggers()}{edit triggers}, so that the
editor is opened with a single click when the star rating item is
selected.
The \c populateTableWidget() function fills the QTableWidget with
data:

View File

@ -43,7 +43,7 @@
from that class, and adding a macro. In this example we extend Qt
by adding a new GUI look and feel (i.e., making a new QStyle
available). A high-level introduction to plugins is given in the
plugin \l{How to Create Qt Plugins}{overview document}.
plugin \l{How to Create Qt Plugins}{overview document}.
Plugins that provide new styles inherit the QStylePlugin base
class. Style plugins are loaded by Qt and made available through
@ -72,7 +72,7 @@
\section1 SimpleStylePlugin Class Definition
\c SimpleStylePlugin inherits QStylePlugin and is the plugin
class.
class.
\snippet tools/styleplugin/plugin/simplestyleplugin.h 0

View File

@ -30,7 +30,7 @@
\title Style Sheet Example
\ingroup examples-widgets
\brief The Style Sheet Example shows how to use style sheets.
\image stylesheet-pagefold.png Screen Shot of the Pagefold style sheet
*/

View File

@ -31,7 +31,7 @@
\brief This example shows Qt's ability to combine \l{The Animation Framework}{the animation framework}
and \l{The State Machine Framework}{the state machine framework} to create a game.
\image sub-attaq-demo.png
The purpose of the game is to destroy all submarines to win the current level.

View File

@ -41,7 +41,7 @@
it is close but not pressed down on it), when a device is pushed
down and released from it, and when a device is moved on the
tablet.
The information available in QTabletEvent depends on the device
used. The tablet in this example has two different devices for
drawing: a stylus and an airbrush. For both devices the event
@ -61,23 +61,23 @@
The example consists of the following:
\list
\li The \c MainWindow class inherits QMainWindow and creates
the examples menus and connect their slots and signals.
\li The \c MainWindow class inherits QMainWindow and creates
the examples menus and connect their slots and signals.
\li The \c TabletCanvas class inherits QWidget and
receives tablet events. It uses the events to paint on a
offscreen pixmap, which it draws onto itself.
receives tablet events. It uses the events to paint on a
offscreen pixmap, which it draws onto itself.
\li The \c TabletApplication class inherits QApplication. This
class handles tablet events that are not sent to \c tabletEvent().
We will look at this later.
class handles tablet events that are not sent to \c tabletEvent().
We will look at this later.
\li The \c main() function creates a \c MainWindow and shows it
as a top level window.
as a top level window.
\endlist
\section1 MainWindow Class Definition
The \c MainWindow creates a \c TabletCanvas and sets it as its
center widget.
The \c MainWindow creates a \c TabletCanvas and sets it as its
center widget.
\snippet widgets/tablet/mainwindow.h 0
@ -115,10 +115,10 @@
\snippet widgets/tablet/mainwindow.cpp 2
The \c TabletCanvas class supports two ways by which the alpha
The \c TabletCanvas class supports two ways by which the alpha
channel of the drawing color can be changed: tablet pressure and
tilt. We have one action for each and an action if the alpha
channel should not be changed.
channel should not be changed.
Here is the implementation of \c lineWidthActionTriggered():
@ -155,12 +155,12 @@
\snippet widgets/tablet/mainwindow.cpp 7
We show a message box with a short description of the example.
We show a message box with a short description of the example.
\c createActions() creates all actions and action groups of
the example. We look at the creation of one action group and its
actions. See the \l{Application Example}{application example} if
you want a high-level introduction to QActions.
you want a high-level introduction to QActions.
Here is the implementation of \c createActions:
@ -189,7 +189,7 @@
\section1 TabletCanvas Class Definition
The \c TabletCanvas class provides a surface on which the
user can draw with a tablet.
user can draw with a tablet.
\snippet widgets/tablet/tabletcanvas.h 0
@ -198,7 +198,7 @@
these; their values decide if it is the tablet pressure or tilt
that will alter them. We keep a private variable for each, the \c
alphaChannelType, \c colorSturationType, and \c penWidthType,
which we provide access functions for.
which we provide access functions for.
We draw on a QPixmap with \c myPen and \c myBrush using \c
myColor. The \c saveImage() and \c loadImage() saves and loads
@ -291,7 +291,7 @@
-60, 127 equals 0, and 255 equals 60 degrees. The angle measured
is between the device and the perpendicular of the tablet (see
QTabletEvent for an illustration).
\snippet widgets/tablet/tabletcanvas.cpp 8
The alpha channel of QColor is given as a number between 0
@ -301,8 +301,8 @@
taking the absolute value we get the smallest alpha values (i.e.,
the color is most transparent) when the pen is perpendicular to
the tablet. We select the largest of the vertical and horizontal
tilt value.
tilt value.
\snippet widgets/tablet/tabletcanvas.cpp 9
The colorsaturation is given as a number between 0 and 255. It is
@ -317,7 +317,7 @@
the angle between the device and the perpendicular of the tablet.
\snippet widgets/tablet/tabletcanvas.cpp 11
We finally check whether the pointer is the stylus or the eraser.
If it is the eraser, we set the color to the background color of
the pixmap an let the pressure decide the pen width, else we set
@ -327,7 +327,7 @@
\section1 TabletApplication Class Definition
We inherit QApplication in this class because we want to
reimplement the \l{QApplication::}{event()} function.
reimplement the \l{QApplication::}{event()} function.
\snippet widgets/tablet/tabletapplication.h 0
@ -336,7 +336,7 @@
and TabletLeaveProximity events are not sendt to the QApplication
object, while other tablet events are sendt to the QWidget's
\c event(), which sends them on to \l{QWidget::}{tabletEvent()}.
Since we want to handle these events we have implemented \c
Since we want to handle these events we have implemented \c
TabletApplication.
@ -352,7 +352,7 @@
events is to do work that is dependent on what kind of device is
used on the tablet. This way, you don't have to do this work
when other events are generated, which is more frequently than the
leave and enter proximity events. We call \c setTabletDevice() in
leave and enter proximity events. We call \c setTabletDevice() in
\c TabletCanvas.
\section1 The \c main() function

View File

@ -25,7 +25,7 @@
**
****************************************************************************/
/*!
/*!
\example widgets/tetrix
\title Tetrix Example
\ingroup examples-widgets

View File

@ -35,7 +35,7 @@
\image undodemo.png
Qt's undo framework is an implementation of the Command
pattern, which provides advanced undo/redo functionality.
pattern, which provides advanced undo/redo functionality.
To show the abilities of the framework, we have implemented a
small diagram application in which the diagram items are geometric

View File

@ -61,9 +61,9 @@
The example consists of the following classes:
\list
\list
\li \c MainWindow is the main window and arranges the
example's widgets. It creates the commands based
example's widgets. It creates the commands based
on user input and keeps them on the command stack.
\li \c AddCommand adds an item to the scene.
\li \c DeleteCommand deletes an item from the scene.
@ -85,23 +85,23 @@
\l{QUndoCommand}s and pushes and pops them from the stack when it
receives the \c triggered() signal from \c undoAction and \c
redoAction.
\section1 MainWindow Class Implementation
We will start with a look at the constructor:
We will start with a look at the constructor:
\snippet tools/undoframework/mainwindow.cpp 0
In the constructor, we set up the DiagramScene and QGraphicsView.
In the constructor, we set up the DiagramScene and QGraphicsView.
Here is the \c createUndoView() function:
Here is the \c createUndoView() function:
\snippet tools/undoframework/mainwindow.cpp 1
The QUndoView is a widget that display the text, which is set with
the \l{QUndoCommand::}{setText()} function, for each QUndoCommand
in the undo stack in a list.
Here is the \c createActions() function:
\snippet tools/undoframework/mainwindow.cpp 2
@ -130,7 +130,7 @@
We have to use the QMenu \c aboutToShow() and \c aboutToHide()
signals since we only want \c deleteAction to be enabled when we
have selected an item.
have selected an item.
Here is the \c itemMoved() slot:
@ -155,9 +155,9 @@
\snippet tools/undoframework/mainwindow.cpp 12
We implement \c itemMenuAboutToShow() and \c itemMenuAboutToHide()
to get a dynamic item menu. These slots are connected to the
to get a dynamic item menu. These slots are connected to the
\l{QMenu::}{aboutToShow()} and \l{QMenu::}{aboutToHide()} signals.
We need this to disable or enable the \c deleteAction.
We need this to disable or enable the \c deleteAction.
Here is the \c addBox() slot:
@ -171,21 +171,21 @@
\snippet tools/undoframework/mainwindow.cpp 14
The \c addTriangle() function creates an AddCommand and pushes it
on the undo stack.
on the undo stack.
Here is the implementation of \c about():
\snippet tools/undoframework/mainwindow.cpp 15
The about slot is triggered by the \c aboutAction and displays an
about box for the example.
\section1 AddCommand Class Definition
\snippet tools/undoframework/commands.h 2
The \c AddCommand class adds DiagramItem graphics items to the
DiagramScene.
DiagramScene.
\section1 AddCommand Class Implementation
@ -208,20 +208,20 @@
constructor.
\section1 DeleteCommand Class Definition
\snippet tools/undoframework/commands.h 1
The DeleteCommand class implements the functionality to remove an
item from the scene.
\section1 DeleteCommand Class Implementation
\snippet tools/undoframework/commands.cpp 4
We know that there must be one selected item as it is not possible
to create a DeleteCommand unless the item to be deleted is
selected and that only one item can be selected at any time.
The item must be unselected if it is inserted back into the
selected and that only one item can be selected at any time.
The item must be unselected if it is inserted back into the
scene.
\snippet tools/undoframework/commands.cpp 5
@ -242,7 +242,7 @@
\section1 MoveCommand Class Implementation
The constructor of MoveCommand looks like this:
\snippet tools/undoframework/commands.cpp 0
@ -252,12 +252,12 @@
\snippet tools/undoframework/commands.cpp 2
We simply set the items old position and update the scene.
We simply set the items old position and update the scene.
\snippet tools/undoframework/commands.cpp 3
We set the item to its new position.
\snippet tools/undoframework/commands.cpp 1
Whenever a MoveCommand is created, this function is called to
@ -268,7 +268,7 @@
We first check whether it is the same item that has been moved
twice, in which case we merge the commands. We update the position
of the item so that it will take the last position in the move
sequence when undone.
sequence when undone.
\section1 DiagramScene Class Definition
@ -281,7 +281,7 @@
as it only deals with graphics framework issues.
\section1 The \c main() Function
The \c main() function of the program looks like this:
\snippet tools/undoframework/main.cpp 0

View File

@ -103,7 +103,7 @@ void DragWidget::dropEvent(QDropEvent *event)
if (event->mimeData()->hasFormat("application/x-dnditemdata")) {
QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
QDataStream dataStream(&itemData, QIODevice::ReadOnly);
QPixmap pixmap;
QPoint offset;
dataStream >> pixmap >> offset;
@ -143,7 +143,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-dnditemdata", itemData);
//! [2]
//! [3]
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);

View File

@ -87,7 +87,7 @@ void DropArea::dropEvent(QDropEvent *event)
setText(mimeData->html());
setTextFormat(Qt::RichText);
} else if (mimeData->hasText()) {
setText(mimeData->text());
setText(mimeData->text());
setTextFormat(Qt::PlainText);
} else if (mimeData->hasUrls()) {
QList<QUrl> urlList = mimeData->urls();
@ -102,7 +102,7 @@ void DropArea::dropEvent(QDropEvent *event)
}
//! [dropEvent() function part2]
//! [dropEvent() function part3]
//! [dropEvent() function part3]
setBackgroundRole(QPalette::Dark);
event->acceptProposedAction();
}

View File

@ -103,7 +103,7 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
return;
//! [updateFormatsTable() part1]
//! [updateFormatsTable() part2]
//! [updateFormatsTable() part2]
foreach (QString format, mimeData->formats()) {
QTableWidgetItem *formatItem = new QTableWidgetItem(format);
formatItem->setFlags(Qt::ItemIsEnabled);
@ -129,7 +129,7 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
text.append(hex + " ");
}
}
//! [updateFormatsTable() part3]
//! [updateFormatsTable() part3]
//! [updateFormatsTable() part4]
int row = formatsTable->rowCount();
@ -137,7 +137,7 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
formatsTable->setItem(row, 0, new QTableWidgetItem(format));
formatsTable->setItem(row, 1, new QTableWidgetItem(text));
}
formatsTable->resizeColumnToContents(0);
}
//! [updateFormatsTable() part4]
//! [updateFormatsTable() part4]

View File

@ -567,7 +567,7 @@ void Scene::initGL()
m_environmentProgram->link();
const int NOISE_SIZE = 128; // for a different size, B and BM in fbm.c must also be changed
m_noise = new GLTexture3D(NOISE_SIZE, NOISE_SIZE, NOISE_SIZE);
m_noise = new GLTexture3D(NOISE_SIZE, NOISE_SIZE, NOISE_SIZE);
QRgb *data = new QRgb[NOISE_SIZE * NOISE_SIZE * NOISE_SIZE];
memset(data, 0, NOISE_SIZE * NOISE_SIZE * NOISE_SIZE * sizeof(QRgb));
QRgb *p = data;

View File

@ -51,7 +51,7 @@ int main(int argc, char *argv[])
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
MainWindow window;
window.show();
window.show();
return app.exec();
}

View File

@ -53,7 +53,7 @@ MainWindow::MainWindow(QWidget *parent)
h1Splitter = new QSplitter;
h2Splitter = new QSplitter;
QSplitter *vSplitter = new QSplitter;
vSplitter->setOrientation(Qt::Vertical);
vSplitter->addWidget(h1Splitter);

View File

@ -54,11 +54,11 @@ class MainWindow : public QWidget
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
private:
void setupMatrix();
void populateScene();
QGraphicsScene *scene;
QSplitter *h1Splitter;
QSplitter *h2Splitter;

View File

@ -159,7 +159,7 @@ void Mouse::advance(int step)
foreach (QGraphicsItem *item, dangerMice) {
if (item == this)
continue;
QLineF lineToMouse(QPointF(0, 0), mapFromItem(item, 0, 0));
qreal angleToMouse = ::acos(lineToMouse.dx() / lineToMouse.length());
if (lineToMouse.dy() < 0)

View File

@ -162,7 +162,7 @@ void RobotTorso::paint(QPainter *painter,
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->setBrush(dragOver ? color.light(130) : color);
painter->drawRoundedRect(-20, -20, 40, 60, 25, 25, Qt::RelativeSize);
painter->drawEllipse(-25, -20, 20, 20);

View File

@ -109,7 +109,7 @@ class Robot : public RobotPart
{
public:
Robot(QGraphicsItem *parent = 0);
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
};

View File

@ -136,7 +136,7 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
QPointF sourceArrowP1 = sourcePoint + QPointF(sin(angle + Pi / 3) * arrowSize,
cos(angle + Pi / 3) * arrowSize);
QPointF sourceArrowP2 = sourcePoint + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
cos(angle + Pi - Pi / 3) * arrowSize);
cos(angle + Pi - Pi / 3) * arrowSize);
QPointF destArrowP1 = destPoint + QPointF(sin(angle - Pi / 3) * arrowSize,
cos(angle - Pi / 3) * arrowSize);
QPointF destArrowP2 = destPoint + QPointF(sin(angle - Pi + Pi / 3) * arrowSize,

View File

@ -58,11 +58,11 @@ public:
enum { Type = UserType + 2 };
int type() const { return Type; }
protected:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
Node *source, *dest;

View File

@ -74,7 +74,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private:
QList<Edge *> edgeList;
QPointF newPos;

View File

@ -64,7 +64,7 @@ void CustomProxy::paintWindowFrame(QPainter *painter, const QStyleOptionGraphics
QWidget *widget)
{
const QColor color(0, 0, 0, 64);
QRectF r = windowFrameRect();
QRectF right(r.right(), r.top() + 10, 10, r.height() - 10);
QRectF bottom(r.left() + 10, r.bottom(), r.width(), 10);
@ -159,7 +159,7 @@ void CustomProxy::zoomIn()
{
if (timeLine->direction() != QTimeLine::Forward)
timeLine->setDirection(QTimeLine::Forward);
if (timeLine->state() == QTimeLine::NotRunning)
if (timeLine->state() == QTimeLine::NotRunning)
timeLine->start();
}
@ -167,6 +167,6 @@ void CustomProxy::zoomOut()
{
if (timeLine->direction() != QTimeLine::Backward)
timeLine->setDirection(QTimeLine::Backward);
if (timeLine->state() == QTimeLine::NotRunning)
if (timeLine->state() == QTimeLine::NotRunning)
timeLine->start();
}

View File

@ -54,7 +54,7 @@ public:
QRectF boundingRect() const;
void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
QWidget *widget);
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);

View File

@ -50,31 +50,31 @@ AddDialog::AddDialog(QWidget *parent)
addressLabel = new QLabel("Address");
okButton = new QPushButton("OK");
cancelButton = new QPushButton("Cancel");
nameText = new QLineEdit;
addressText = new QTextEdit;
QGridLayout *gLayout = new QGridLayout;
gLayout->setColumnStretch(1, 2);
gLayout->addWidget(nameLabel, 0, 0);
gLayout->addWidget(nameText, 0, 1);
gLayout->addWidget(addressLabel, 1, 0, Qt::AlignLeft|Qt::AlignTop);
gLayout->addWidget(addressText, 1, 1, Qt::AlignLeft);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(okButton);
buttonLayout->addWidget(cancelButton);
gLayout->addLayout(buttonLayout, 2, 1, Qt::AlignRight);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(gLayout);
setLayout(mainLayout);
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
setWindowTitle(tr("Add a Contact"));
}
//! [0]

View File

@ -54,7 +54,7 @@ QT_END_NAMESPACE
class AddDialog : public QDialog
{
Q_OBJECT
public:
AddDialog(QWidget *parent = 0);
QLineEdit *nameText;

View File

@ -52,7 +52,7 @@ AddressWidget::AddressWidget(QWidget *parent)
connect(newAddressTab, SIGNAL(sendDetails(QString, QString)),
this, SLOT(addEntry(QString, QString)));
addTab(newAddressTab, "Address Book");
addTab(newAddressTab, "Address Book");
setupTabs();
}
@ -60,13 +60,13 @@ AddressWidget::AddressWidget(QWidget *parent)
//! [2]
void AddressWidget::addEntry()
{
{
AddDialog aDialog;
if (aDialog.exec()) {
QString name = aDialog.nameText->text();
QString address = aDialog.addressText->toPlainText();
addEntry(name, address);
}
}
@ -74,7 +74,7 @@ void AddressWidget::addEntry()
//! [3]
void AddressWidget::addEntry(QString name, QString address)
{
{
QList<QPair<QString, QString> >list = table->getList();
QPair<QString, QString> pair(name, address);
@ -110,14 +110,14 @@ void AddressWidget::editEntry()
QModelIndex nameIndex = table->index(row, 0, QModelIndex());
QVariant varName = table->data(nameIndex, Qt::DisplayRole);
name = varName.toString();
QModelIndex addressIndex = table->index(row, 1, QModelIndex());
QVariant varAddr = table->data(addressIndex, Qt::DisplayRole);
address = varAddr.toString();
}
//! [4a]
//! [4b]
//! [4b]
AddDialog aDialog;
aDialog.setWindowTitle(tr("Edit a Contact"));
@ -141,7 +141,7 @@ void AddressWidget::removeEntry()
QTableView *temp = static_cast<QTableView*>(currentWidget());
QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(temp->model());
QItemSelectionModel *selectionModel = temp->selectionModel();
QModelIndexList indexes = selectionModel->selectedRows();
foreach (QModelIndex index, indexes) {
@ -163,7 +163,7 @@ void AddressWidget::setupTabs()
for (int i = 0; i < groups.size(); ++i) {
QString str = groups.at(i);
proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(table);
@ -181,7 +181,7 @@ void AddressWidget::setupTabs()
proxyModel->setFilterRegExp(QRegExp(newStr, Qt::CaseInsensitive));
proxyModel->setFilterKeyColumn(0);
proxyModel->sort(0, Qt::AscendingOrder);
connect(tableView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SIGNAL(selectionChanged(QItemSelection)));

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