diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-06-18 15:31:28 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-06-18 15:31:28 (GMT) |
commit | 1fa6b99c373e0dab9e0a0b7f190e3085190be668 (patch) | |
tree | 1c5181e125a7ebae7b10d8a3fbb53e1cf0e63b3a /doc/src | |
parent | a18e5288324aa13da014ee52daffbfc589c87be3 (diff) | |
parent | f9f08de9d41fd55d9c7d01578191ef5d4099c9e6 (diff) | |
download | Qt-1fa6b99c373e0dab9e0a0b7f190e3085190be668.zip Qt-1fa6b99c373e0dab9e0a0b7f190e3085190be668.tar.gz Qt-1fa6b99c373e0dab9e0a0b7f190e3085190be668.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into qt-main/qgraphicssceneindex
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/animation.qdoc | 6 | ||||
-rw-r--r-- | doc/src/known-issues.qdoc | 7 | ||||
-rw-r--r-- | doc/src/qnamespace.qdoc | 6 | ||||
-rw-r--r-- | doc/src/snippets/qstring/stringbuilder.cpp | 28 | ||||
-rw-r--r-- | doc/src/snippets/statemachine/main.cpp | 48 | ||||
-rw-r--r-- | doc/src/snippets/statemachine/main2.cpp | 51 | ||||
-rw-r--r-- | doc/src/snippets/statemachine/main3.cpp | 21 | ||||
-rw-r--r-- | doc/src/snippets/statemachine/main4.cpp | 71 | ||||
-rw-r--r-- | doc/src/snippets/statemachine/main5.cpp | 103 | ||||
-rw-r--r-- | doc/src/statemachine.qdoc | 141 |
10 files changed, 344 insertions, 138 deletions
diff --git a/doc/src/animation.qdoc b/doc/src/animation.qdoc index 843e0aa..da9b401 100644 --- a/doc/src/animation.qdoc +++ b/doc/src/animation.qdoc @@ -208,12 +208,6 @@ Note that QObject must be the first class inherited as the meta-object system demands this. - \warning The QItemAnimation class, which was initially intended - for animating \l{QGraphicsItem}s may be deprecated or removed from - the animation framework. - - \omit (need something about the list of animations). \endomit - \section1 Easing Curves As mentioned, QPropertyAnimation performs an interpolation between diff --git a/doc/src/known-issues.qdoc b/doc/src/known-issues.qdoc index e005b14..9c90908 100644 --- a/doc/src/known-issues.qdoc +++ b/doc/src/known-issues.qdoc @@ -58,13 +58,6 @@ \section1 Issues with Third Party Software - \section2 Intel Compiler Support - - Although it is possible to build applications against Qt 4.5.x using Intel - CC 10, these applications will crash when run. We recommend that developers - who rely on this compiler wait until a fix is available before upgrading to - the Qt 4.5.x series of releases. - \section2 X11 Hardware Support \list diff --git a/doc/src/qnamespace.qdoc b/doc/src/qnamespace.qdoc index d46236f..8a24764 100644 --- a/doc/src/qnamespace.qdoc +++ b/doc/src/qnamespace.qdoc @@ -2685,3 +2685,9 @@ \value Round Like Repeat, but scales the images down to ensure that the last image is not cropped. */ + +/*! + \enum Uninitialized + \internal +*/ + diff --git a/doc/src/snippets/qstring/stringbuilder.cpp b/doc/src/snippets/qstring/stringbuilder.cpp new file mode 100644 index 0000000..90803e2 --- /dev/null +++ b/doc/src/snippets/qstring/stringbuilder.cpp @@ -0,0 +1,28 @@ + +//! [0] + QString foo; + QString type = "long"; + + foo->setText(QLatin1String("vector<") + type + QLatin1String(">::iterator")); + + if (foo.startsWith("(" + type + ") 0x")) + ... +//! [0] + +//! [3] + #define QT_USE_FAST_CONCATENATION +//! [3] + +//! [4] + #define QT_USE_FAST_CONCATENATION + #define QT_USE_FAST_OPERATOR_PLUS +//! [4] + +//! [5] + #include <QStringBuilder> + + QString hello("hello"); + QStringRef el(&hello, 2, 3); + QLatin1String world("world"); + QString message = hello % el % world % QChar('!'); +//! [5] diff --git a/doc/src/snippets/statemachine/main.cpp b/doc/src/snippets/statemachine/main.cpp new file mode 100644 index 0000000..f20d245 --- /dev/null +++ b/doc/src/snippets/statemachine/main.cpp @@ -0,0 +1,48 @@ + +#include <QtGui> + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + QLabel *label = new QLabel; + +//![0] + QStateMachine machine; + QState *s1 = new QState(); + QState *s2 = new QState(); + QState *s3 = new QState(); +//![0] + +//![4] + s1->assignProperty(label, "text", "In state s1"); + s2->assignProperty(label, "text", "In state s2"); + s3->assignProperty(label, "text", "In state s3"); +//![4] + +//![5] + QObject::connect(s3, SIGNAL(entered()), button, SLOT(showMaximized())); + QObject::connect(s3, SIGNAL(exited()), button, SLOT(showMinimized())); +//![5] + +//![1] + s1->addTransition(button, SIGNAL(clicked()), s2); + s2->addTransition(button, SIGNAL(clicked()), s3); + s3->addTransition(button, SIGNAL(clicked()), s1); +//![1] + +//![2] + machine.addState(s1); + machine.addState(s2); + machine.addState(s3); + machine.setInitialState(s1); +//![2] + +//![3] + machine.start(); +//![3] + + label->show(); + + return app.exec(); +} diff --git a/doc/src/snippets/statemachine/main2.cpp b/doc/src/snippets/statemachine/main2.cpp new file mode 100644 index 0000000..60a61e7 --- /dev/null +++ b/doc/src/snippets/statemachine/main2.cpp @@ -0,0 +1,51 @@ + +#include <QtGui> + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + QStateMachine machine; + +//![0] + QState *s1 = new QState(); + QState *s11 = new QState(s1); + QState *s12 = new QState(s1); + QState *s13 = new QState(s1); + s1->setInitialState(s11); + machine.addState(s1); +//![0] + +//![2] + s12>addTransition(quitButton, SIGNAL(clicked()), s12); +//![2] + +//![1] + QFinalState *s2 = new QFinalState(); + s1->addTransition(quitButton, SIGNAL(clicked()), s2); + machine.addState(s2); + + QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit())); +//![1] + + QButton *interruptButton = new QPushButton("Interrupt Button"); + +//![3] + QHistoryState *s1h = s1->addHistoryState(); + + QState *s3 = new QState(); + s3->assignProperty(label, "text", "In s3"); + QMessageBox mbox; + mbox.addButton(QMessageBox::Ok); + mbox.setText("Interrupted!"); + mbox.setIcon(QMessageBox::Information); + QObject::connect(s3, SIGNAL(entered()), &mbox, SLOT(exec())); + s3->addTransition(s1h); + machine.addState(s3); + + s1->addTransition(interruptButton, SIGNAL(clicked()), s3); +//![3] + + return app.exec(); +} + diff --git a/doc/src/snippets/statemachine/main3.cpp b/doc/src/snippets/statemachine/main3.cpp new file mode 100644 index 0000000..b04b850 --- /dev/null +++ b/doc/src/snippets/statemachine/main3.cpp @@ -0,0 +1,21 @@ + +#include <QtGui> + +int main(int argv, char **args) +{ + QApplication app(argv, args); + +//![0] + QState *s1 = new QState(QState::ParallelStates); + // s11 and s12 will be entered in parallel + QState *s11 = new QState(s1); + QState *s12 = new QState(s1); +//![0] + +//![1] + s1->addTransition(s1, SIGNAL(finished()), s2); +//![1] + + return app.exec(); +} + diff --git a/doc/src/snippets/statemachine/main4.cpp b/doc/src/snippets/statemachine/main4.cpp new file mode 100644 index 0000000..5681bbd --- /dev/null +++ b/doc/src/snippets/statemachine/main4.cpp @@ -0,0 +1,71 @@ + +#include <QtGui> + + +//![0] +struct StringEvent : public QEvent +{ + StringEvent(const QString &val) + : QEvent(QEvent::Type(QEvent::User+1)), + value(val) {} + + QString value; +}; +//![0] + +//![1] +class StringTransition : public QAbstractTransition +{ +public: + StringTransition(const QString &value) + : m_value(value) {} + +protected: + virtual bool eventTest(QEvent *e) const + { + if (e->type() != QEvent::Type(QEvent::User+1)) // StringEvent + return false; + StringEvent *se = static_cast<StringEvent*>(e); + return (m_value == se->value); + } + + virtual void onTransition(QEvent *) {} + +private: + QString m_value; +}; +//![1] + +int main(int argv, char **args) +{ + QApplication app(argv, args); + +//![2] + QStateMachine machine; + QState *s1 = new QState(); + QState *s2 = new QState(); + QFinalState *done = new QFinalState(); + + StringTransition *t1 = new StringTransition("Hello"); + t1->setTargetState(s2); + s1->addTransition(t1); + StringTransition *t2 = new StringTransition("world"); + t2->setTargetState(done); + s2->addTransition(t2); + + machine.addState(s1); + machine.addState(s2); + machine.addState(done); + machine.setInitialState(s1); +//![2] + +//![3] + machine.postEvent(new StringEvent("Hello")); + machine.postEvent(new StringEvent("world")); +//![3] + + return app.exec(); +} + +#include "main4.moc" + diff --git a/doc/src/snippets/statemachine/main5.cpp b/doc/src/snippets/statemachine/main5.cpp new file mode 100644 index 0000000..90ad8c7 --- /dev/null +++ b/doc/src/snippets/statemachine/main5.cpp @@ -0,0 +1,103 @@ + +#include <QtGui> + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + { +//![0] + QStateMachine machine; + machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties); +//![0] + +//![1] + QState *s1 = new QState(); + s1->assignProperty(object, "fooBar", 1.0); + machine.addState(s1); + machine.setInitialState(s1); + + QState *s2 = new QState(); + machine.addState(s2); +//![1] + } + + { + +//![2] + QStateMachine machine; + machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties); + + QState *s1 = new QState(); + s1->assignProperty(object, "fooBar", 1.0); + machine.addState(s1); + machine.setInitialState(s1); + + QState *s2 = new QState(s1); + s2->assignProperty(object, "fooBar", 2.0); + s1->setInitialState(s2); + + QState *s3 = new QState(s1); +//![2] + + } + + { +//![3] + QState *s1 = new QState(); + QState *s2 = new QState(); + + s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); + s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100)); + + s1->addTransition(button, SIGNAL(clicked()), s2); +//![3] + + } + + { +//![4] + QState *s1 = new QState(); + QState *s2 = new QState(); + + s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); + s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100)); + + QSignalTransition *transition = s1->addTransition(button, SIGNAL(clicked()), s2); + transition->addAnimation(new QPropertyAnimation(button, "geometry")); +//![4] + + } + + { + +//![5] + QState *s1 = new QState(); + s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); + + QState *s2 = new QState(); + + s1->addTransition(s1, SIGNAL(polished()), s2); +//![5] + + } + + { + +//![6] + QState *s1 = new QState(); + QState *s2 = new QState(); + + s2->assignProperty(object, "fooBar", 2.0); + s1->addTransition(s2); + + QStateMachine machine; + machine.setInitialState(s1); + machine.addDefaultAnimation(new QPropertyAnimation(object, "fooBar")); +//![6] + + } + + return app.exec(); +} + diff --git a/doc/src/statemachine.qdoc b/doc/src/statemachine.qdoc index c017827..d2b508d 100644 --- a/doc/src/statemachine.qdoc +++ b/doc/src/statemachine.qdoc @@ -85,36 +85,20 @@ The following snippet shows the code needed to create such a state machine. First, we create the state machine and states: - \code - QStateMachine machine; - QState *s1 = new QState(); - QState *s2 = new QState(); - QState *s3 = new QState(); - \endcode + \snippet doc/src/snippets/statemachine/main.cpp 0 Then, we create the transitions by using the QState::addTransition() function: - \code - s1->addTransition(button, SIGNAL(clicked()), s2); - s2->addTransition(button, SIGNAL(clicked()), s3); - s3->addTransition(button, SIGNAL(clicked()), s1); - \endcode + \snippet doc/src/snippets/statemachine/main.cpp 1 Next, we add the states to the machine and set the machine's initial state: - \code - machine.addState(s1); - machine.addState(s2); - machine.addState(s3); - machine.setInitialState(s1); - \endcode + \snippet doc/src/snippets/statemachine/main.cpp 2 Finally, we start the state machine: - \code - machine.start(); - \endcode + \snippet doc/src/snippets/statemachine/main.cpp 3 The state machine executes asynchronously, i.e. it becomes part of your application's event loop. @@ -127,11 +111,7 @@ entered. In the following snippet, the value that should be assigned to a QLabel's text property is specified for each state: - \code - s1->assignProperty(label, "text", "In state s1"); - s2->assignProperty(label, "text", "In state s2"); - s3->assignProperty(label, "text", "In state s3"); - \endcode + \snippet doc/src/snippets/statemachine/main.cpp 4 When any of the states is entered, the label's text will be changed accordingly. @@ -142,10 +122,7 @@ state \c s3 is entered, and the button's showMinimized() slot will be called when \c s3 is exited: - \code - QObject::connect(s3, SIGNAL(entered()), button, SLOT(showMaximized())); - QObject::connect(s3, SIGNAL(exited()), button, SLOT(showMinimized())); - \endcode + \snippet doc/src/snippets/statemachine/main.cpp 5 Custom states can reimplement QAbstractState::onEntry() and QAbstractState::onExit(). @@ -194,22 +171,9 @@ initial one (i.e. which child state the state machine should enter when the parent state is the target of a transition). - \code - QState *s1 = new QState(); - QState *s11 = new QState(s1); - QState *s12 = new QState(s1); - QState *s13 = new QState(s1); - s1->setInitialState(s11); - machine.addState(s1); - \endcode + \snippet doc/src/snippets/statemachine/main2.cpp 0 - \code - QFinalState *s2 = new QFinalState(); - s1->addTransition(quitButton, SIGNAL(clicked()), s2); - machine.addState(s2); - - QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit())); - \endcode + \snippet doc/src/snippets/statemachine/main2.cpp 1 In this case we want the application to quit when the state machine is finished, so the machine's finished() signal is connected to the @@ -219,9 +183,7 @@ following code adds a transition that effectively causes the Quit button to be ignored when the state machine is in state \c s12. - \code - s12>addTransition(quitButton, SIGNAL(clicked()), s12); - \endcode + \snippet doc/src/snippets/statemachine/main2.cpp 2 A transition can have any state as its target, i.e. the target state does not have to be on the same level in the state hierarchy as the source state. @@ -259,21 +221,7 @@ simply display a message box when \c s3 is entered, then immediately return to the previous child state of \c s1 via the history state. - \code - QHistoryState *s1h = s1->addHistoryState(); - - QState *s3 = new QState(); - s3->assignProperty(label, "text", "In s3"); - QMessageBox mbox; - mbox.addButton(QMessageBox::Ok); - mbox.setText("Interrupted!"); - mbox.setIcon(QMessageBox::Information); - QObject::connect(s3, SIGNAL(entered()), &mbox, SLOT(exec())); - s3->addTransition(s1h); - machine.addState(s3); - - s1->addTransition(interruptButton, SIGNAL(clicked()), s3); - \endcode + \snippet doc/src/snippets/statemachine/main2.cpp 3 \section1 Using Parallel States to Avoid a Combinatorial Explosion of States @@ -305,12 +253,7 @@ To create a parallel state group, pass QState::ParallelStates to the QState constructor. - \code - QState *s1 = new QState(QState::ParallelStates); - // s11 and s12 will be entered in parallel - QState *s11 = new QState(s1); - QState *s12 = new QState(s1); - \endcode + \snippet doc/src/snippets/statemachine/main3.cpp 0 When a parallel state group is entered, all its child states will be simultaneously entered. Transitions within the individual child states @@ -334,9 +277,7 @@ finished(). We use a signal transition to cause this event to trigger a state change: - \code - s1->addTransition(s1, SIGNAL(finished()), s2); - \endcode + \snippet doc/src/snippets/statemachine/main3.cpp 1 Using final states in composite states is useful when you want to hide the internal details of a composite state; i.e. the only thing the outside world @@ -372,42 +313,12 @@ Here we define our own custom event type, \c StringEvent, for posting strings to the state machine: - \code - struct StringEvent : public QEvent - { - StringEvent(const QString &val) - : QEvent(QEvent::Type(QEvent::User+1)), - value(val) {} - - QString value; - }; - \endcode + \snippet doc/src/snippets/statemachine/main4.cpp 0 Next, we define a transition that only triggers when the event's string matches a particular string (a \e guarded transition): - \code - class StringTransition : public QAbstractTransition - { - public: - StringTransition(const QString &value) - : m_value(value) {} - - protected: - virtual bool eventTest(QEvent *e) const - { - if (e->type() != QEvent::Type(QEvent::User+1)) // StringEvent - return false; - StringEvent *se = static_cast<StringEvent*>(e); - return (m_value == se->value); - } - - virtual void onTransition(QEvent *) {} - - private: - QString m_value; - }; - \endcode + \snippet doc/src/snippets/statemachine/main4.cpp 1 In the eventTest() reimplementation, we first check if the event type is the desired one; if so, we cast the event to a StringEvent and perform the @@ -422,31 +333,11 @@ Here's what the implementation of the statechart looks like: - \code - QStateMachine machine; - QState *s1 = new QState(); - QState *s2 = new QState(); - QFinalState *done = new QFinalState(); - - StringTransition *t1 = new StringTransition("Hello"); - t1->setTargetState(s2); - s1->addTransition(t1); - StringTransition *t2 = new StringTransition("world"); - t2->setTargetState(done); - s2->addTransition(t2); - - machine.addState(s1); - machine.addState(s2); - machine.addState(done); - machine.setInitialState(s1); - \endcode + \snippet doc/src/snippets/statemachine/main4.cpp 2 Once the machine is started, we can post events to it. - \code - machine.postEvent(new StringEvent("Hello")); - machine.postEvent(new StringEvent("world")); - \endcode + \snippet doc/src/snippets/statemachine/main4.cpp 3 An event that is not handled by any relevant transition will be silently consumed by the state machine. It can be useful to group states and provide |