Squashed commit of the changes from the mobile-examples repository

(4.7-generated-declarative branch).
This commit is contained in:
David Boddie 2011-04-27 19:16:41 +02:00
parent 5feefb0c03
commit 0748751c9f
474 changed files with 3193 additions and 670 deletions

View File

@ -29,7 +29,7 @@
\example network/broadcastreceiver
\title Broadcast Receiver Example
The Broadcast Receiever example shows how to receive information that is broadcasted
The Broadcast Receiver example shows how to receive information that is broadcasted
over a local network.
\image broadcastreceiver-example.png

View File

@ -29,7 +29,7 @@
\example itemviews/combowidgetmapper
\title Combo Widget Mapper Example
The Delegate Widget Mapper example shows how to use a custom delegate to
The Combo Widget Mapper example shows how to use a custom delegate to
map information from a model to specific widgets on a form.
\image combowidgetmapper-example.png

View File

@ -29,7 +29,7 @@
\example graphicsview/dragdroprobot
\title Drag and Drop Robot Example
This GraphicsView example shows how to implement Drag and Drop in a
The Drag and Drop Robot example shows how to implement Drag and Drop in a
QGraphicsItem subclass, as well as how to animate items using Qt's
\l{Animation Framework}.

View File

@ -29,7 +29,7 @@
\example graphicsview/elasticnodes
\title Elastic Nodes Example
This GraphicsView example shows how to implement edges between nodes in a
The Elastic Nodes example shows how to implement edges between nodes in a
graph, with basic interaction. You can click to drag a node around, and
zoom in and out using the mouse wheel or the keyboard. Hitting the space
bar will randomize the nodes. The example is also resolution independent;

View File

@ -29,7 +29,7 @@
\example xml/rsslisting
\title RSS-Listing Example
This example shows how to create a widget that displays news items
The RSS-Listing example shows how to create a widget that displays news items
from RDF news sources.
\image rsslistingexample.png

View File

@ -104,7 +104,6 @@
array of the data elements that the user can change. The table widget can be
integrated into a program flow by reading and writing the data elements that
the table widget provides.
This method is very intuitive and useful in many applications, but displaying
and editing a database table with a standard table widget can be problematic.
Two copies of the data have to be coordinated: one outside the

View File

@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000D7D1
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -210,7 +210,11 @@ int main(int argc, char **argv)
view->setBackgroundBrush(bgPix);
view->setCacheMode(QGraphicsView::CacheBackground);
view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
#ifdef Q_OS_SYMBIAN
view->showMaximized();
#else
view->show();
#endif
QStateMachine states;
states.addState(rootState);

View File

@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000E3F5
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -80,6 +80,21 @@ private:
QPixmap p;
};
class GraphicsView : public QGraphicsView
{
Q_OBJECT
public:
GraphicsView(QGraphicsScene *scene, QWidget *parent = 0) : QGraphicsView(scene, parent)
{
}
virtual void resizeEvent(QResizeEvent *event)
{
fitInView(sceneRect(), Qt::KeepAspectRatio);
}
};
void createStates(const QObjectList &objects,
const QRect &selectedRect, QState *parent)
{
@ -112,10 +127,10 @@ int main(int argc, char **argv)
p3->setObjectName("p3");
p4->setObjectName("p4");
p1->setGeometry(QRectF(0.0, 0.0, 64.0, 64.0));
p2->setGeometry(QRectF(236.0, 0.0, 64.0, 64.0));
p1->setGeometry(QRectF( 0.0, 0.0, 64.0, 64.0));
p2->setGeometry(QRectF(236.0, 0.0, 64.0, 64.0));
p3->setGeometry(QRectF(236.0, 236.0, 64.0, 64.0));
p4->setGeometry(QRectF(0.0, 236.0, 64.0, 64.0));
p4->setGeometry(QRectF( 0.0, 236.0, 64.0, 64.0));
QGraphicsScene scene(0, 0, 300, 300);
scene.setBackgroundBrush(Qt::white);
@ -124,7 +139,7 @@ int main(int argc, char **argv)
scene.addItem(p3);
scene.addItem(p4);
QGraphicsView window(&scene);
GraphicsView window(&scene);
window.setFrameStyle(0);
window.setAlignment(Qt::AlignLeft | Qt::AlignTop);
window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -135,12 +150,13 @@ int main(int argc, char **argv)
QState *group = new QState(&machine);
group->setObjectName("group");
QRect selectedRect(86, 86, 128, 128);
QState *idleState = new QState(group);
group->setInitialState(idleState);
QObjectList objects;
QObjectList objects;
objects << p1 << p2 << p3 << p4;
createStates(objects, selectedRect, group);
createAnimations(objects, &machine);
@ -148,8 +164,12 @@ int main(int argc, char **argv)
machine.setInitialState(group);
machine.start();
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
window.showMaximized();
#else
window.resize(300, 300);
window.show();
#endif
return app.exec();
}

View File

@ -5,7 +5,7 @@ SOURCES = main.cpp \
FORMS = form.ui
RESOURCES = easing.qrc
RESOURCES = easing.qrc
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/animation/easing
@ -17,3 +17,5 @@ symbian {
TARGET.UID3 = 0xA000E3F6
CONFIG += qt_example
}
maemo5: CONFIG += qt_example

View File

@ -49,12 +49,27 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>Path type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QRadioButton" name="lineRadio">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Line</string>
</property>
@ -66,8 +81,14 @@
</attribute>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QRadioButton" name="circleRadio">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>Circle</string>
</property>
@ -96,6 +117,18 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Period</string>
</property>
@ -106,6 +139,18 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
@ -117,18 +162,52 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Amplitude</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="amplitudeSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>-1.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Overshoot</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="overshootSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
@ -141,25 +220,15 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Overshoot</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="overshootSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>-1.000000000000000</double>
<string>Amplitude</string>
</property>
</widget>
</item>

View File

@ -46,7 +46,15 @@ int main(int argc, char **argv)
Q_INIT_RESOURCE(easing);
QApplication app(argc, argv);
Window w;
#if defined(Q_OS_SYMBIAN)
w.showMaximized();
#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
w.show();
#else
w.resize(400, 400);
w.show();
#endif
return app.exec();
}

View File

@ -41,7 +41,12 @@
#include "window.h"
Window::Window(QWidget *parent)
: QWidget(parent), m_iconSize(64, 64)
: QWidget(parent),
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
m_iconSize(32, 32)
#else
m_iconSize(64, 64)
#endif
{
m_ui.setupUi(this);
QButtonGroup *buttonGroup = findChild<QButtonGroup *>(); // ### workaround for uic in 4.4

View File

@ -39,7 +39,6 @@
****************************************************************************/
#include <QtGui>
#include "ui_form.h"
#include "animation.h"
@ -73,6 +72,4 @@ private:
PixmapItem *m_item;
Animation *m_anim;
QSize m_iconSize;
};

View File

@ -154,25 +154,28 @@ QState *createGeometryState(QObject *w1, const QRect &rect1,
}
//![13]
class GraphicsView : public QGraphicsView
{
Q_OBJECT
public:
GraphicsView(QGraphicsScene *scene, QWidget *parent = NULL) : QGraphicsView(scene, parent)
{
}
protected:
virtual void resizeEvent(QResizeEvent *event)
{
fitInView(scene()->sceneRect());
QGraphicsView::resizeEvent(event);
}
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
#if 0
QWidget window;
QPalette palette;
palette.setBrush(QPalette::Window, Qt::black);
window.setPalette(palette);
QPushButton *button1 = new QPushButton("A", &window);
QPushButton *button2 = new QPushButton("B", &window);
QPushButton *button3 = new QPushButton("C", &window);
QPushButton *button4 = new QPushButton("D", &window);
button1->setObjectName("button1");
button2->setObjectName("button2");
button3->setObjectName("button3");
button4->setObjectName("button4");
#else
//![1]
QGraphicsRectWidget *button1 = new QGraphicsRectWidget;
QGraphicsRectWidget *button2 = new QGraphicsRectWidget;
@ -188,12 +191,11 @@ int main(int argc, char **argv)
scene.addItem(button3);
scene.addItem(button4);
//![1]
QGraphicsView window(&scene);
GraphicsView window(&scene);
window.setFrameStyle(0);
window.setAlignment(Qt::AlignLeft | Qt::AlignTop);
window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
#endif
//![2]
QStateMachine machine;
@ -308,8 +310,13 @@ int main(int argc, char **argv)
machine.start();
//![9]
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
window.showMaximized();
window.fitInView(scene.sceneRect() );
#else
window.resize(300, 300);
window.show();
#endif
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));

View File

@ -10,3 +10,4 @@ symbian {
TARGET.UID3 = 0xA000E3F7
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -62,6 +62,19 @@ private:
QPixmap p;
};
class GraphicsView : public QGraphicsView
{
public:
GraphicsView(QGraphicsScene *scene) : QGraphicsView(scene)
{
}
virtual void resizeEvent(QResizeEvent *event)
{
fitInView(sceneRect(), Qt::KeepAspectRatio);
}
};
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(states);
@ -130,12 +143,12 @@ int main(int argc, char *argv[])
state1->assignProperty(button, "text", "Switch to state 2");
state1->assignProperty(widget, "geometry", QRectF(0, 0, 400, 150));
state1->assignProperty(box, "geometry", QRect(-200, 150, 200, 150));
state1->assignProperty(p1, "pos", QPointF(68, 185));
state1->assignProperty(p2, "pos", QPointF(168, 185));
state1->assignProperty(p3, "pos", QPointF(268, 185));
state1->assignProperty(p4, "pos", QPointF(68-150, 48-150));
state1->assignProperty(p5, "pos", QPointF(168, 48-150));
state1->assignProperty(p6, "pos", QPointF(268+150, 48-150));
state1->assignProperty(p1, "pos", QPointF(68, 200)); // 185));
state1->assignProperty(p2, "pos", QPointF(168, 200)); // 185));
state1->assignProperty(p3, "pos", QPointF(268, 200)); // 185));
state1->assignProperty(p4, "pos", QPointF(68 - 150, 48 - 150));
state1->assignProperty(p5, "pos", QPointF(168, 48 - 150));
state1->assignProperty(p6, "pos", QPointF(268 + 150, 48 - 150));
state1->assignProperty(p1, "rotation", qreal(0));
state1->assignProperty(p2, "rotation", qreal(0));
state1->assignProperty(p3, "rotation", qreal(0));
@ -154,9 +167,9 @@ int main(int argc, char *argv[])
state2->assignProperty(button, "text", "Switch to state 3");
state2->assignProperty(widget, "geometry", QRectF(200, 150, 200, 150));
state2->assignProperty(box, "geometry", QRect(9, 150, 190, 150));
state2->assignProperty(p1, "pos", QPointF(68-150, 185+150));
state2->assignProperty(p2, "pos", QPointF(168, 185+150));
state2->assignProperty(p3, "pos", QPointF(268+150, 185+150));
state2->assignProperty(p1, "pos", QPointF(68 - 150, 185 + 150));
state2->assignProperty(p2, "pos", QPointF(168, 185 + 150));
state2->assignProperty(p3, "pos", QPointF(268 + 150, 185 + 150));
state2->assignProperty(p4, "pos", QPointF(64, 48));
state2->assignProperty(p5, "pos", QPointF(168, 48));
state2->assignProperty(p6, "pos", QPointF(268, 48));
@ -262,8 +275,13 @@ int main(int argc, char *argv[])
machine.start();
QGraphicsView view(&scene);
GraphicsView view(&scene);
#if defined(Q_OS_SYMBIAN)
view.showMaximized();
#else
view.show();
#endif
return app.exec();
}

View File

@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000E3F8
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -54,4 +54,7 @@ void GraphicsView::keyPressEvent(QKeyEvent *e)
emit keyPressed(Qt::Key(e->key()));
}
void GraphicsView::resizeEvent(QResizeEvent *event)
{
fitInView(scene()->sceneRect());
}

View File

@ -51,6 +51,7 @@ public:
GraphicsView(QWidget *parent = 0);
protected:
virtual void resizeEvent(QResizeEvent *event);
void keyPressEvent(QKeyEvent *);
signals:

View File

@ -159,10 +159,14 @@ void LifeCycle::start()
m_machine->start();
}
void LifeCycle::addActivity(const QString &fileName, Qt::Key key)
void LifeCycle::addActivity(const QString &fileName, Qt::Key key, QObject *sender, const char *signal)
{
QState *state = makeState(m_alive, fileName);
m_alive->addTransition(new KeyPressTransition(m_keyReceiver, key, state));
if((sender != NULL) || (signal != NULL)) {
m_alive->addTransition(sender, signal, state);
}
}
QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName)

View File

@ -50,6 +50,7 @@ class QAnimationGroup;
class QState;
class QAbstractState;
class QAbstractTransition;
class QObject;
QT_END_NAMESPACE
class GraphicsView;
class LifeCycle
@ -59,7 +60,7 @@ public:
~LifeCycle();
void setDeathAnimation(const QString &fileName);
void addActivity(const QString &fileName, Qt::Key key);
void addActivity(const QString &fileName, Qt::Key key, QObject *sender = NULL, const char *signal = NULL);
void start();

View File

@ -43,6 +43,7 @@
#include "lifecycle.h"
#include "stickman.h"
#include "graphicsview.h"
#include "rectbutton.h"
#include <QtCore>
#include <QtGui>
@ -55,6 +56,11 @@ int main(int argc, char **argv)
StickMan *stickMan = new StickMan;
stickMan->setDrawSticks(false);
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
RectButton *buttonJump = new RectButton("Jump"); buttonJump->setPos(100, 125);
RectButton *buttonDance = new RectButton("Dance"); buttonDance->setPos(100, 200);
RectButton *buttonChill = new RectButton("Chill"); buttonChill->setPos(100, 275);
#else
QGraphicsTextItem *textItem = new QGraphicsTextItem();
textItem->setHtml("<font color=\"white\"><b>Stickman</b>"
"<p>"
@ -71,31 +77,55 @@ int main(int argc, char **argv)
qreal w = textItem->boundingRect().width();
QRectF stickManBoundingRect = stickMan->mapToScene(stickMan->boundingRect()).boundingRect();
textItem->setPos(-w / 2.0, stickManBoundingRect.bottom() + 25.0);
#endif
QGraphicsScene scene;
scene.addItem(stickMan);
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
scene.addItem(buttonJump);
scene.addItem(buttonDance);
scene.addItem(buttonChill);
#else
scene.addItem(textItem);
#endif
scene.setBackgroundBrush(Qt::black);
GraphicsView view;
view.setRenderHints(QPainter::Antialiasing);
view.setTransformationAnchor(QGraphicsView::NoAnchor);
view.setScene(&scene);
view.show();
view.setFocus();
QRectF sceneRect = scene.sceneRect();
// making enough room in the scene for stickman to jump and die
view.resize(sceneRect.width() + 100, sceneRect.height() + 100);
view.setSceneRect(sceneRect);
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.showMaximized();
view.fitInView(scene.sceneRect(), Qt::KeepAspectRatio);
#else
view.show();
view.setFocus();
#endif
LifeCycle cycle(stickMan, &view);
cycle.setDeathAnimation(":/animations/dead");
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
cycle.addActivity(":/animations/jumping", Qt::Key_J, buttonJump, SIGNAL(clicked()));
cycle.addActivity(":/animations/dancing", Qt::Key_D, buttonDance, SIGNAL(clicked()));
cycle.addActivity(":/animations/chilling", Qt::Key_C, buttonChill, SIGNAL(clicked()));
#else
cycle.addActivity(":/animations/jumping", Qt::Key_J);
cycle.addActivity(":/animations/dancing", Qt::Key_D);
cycle.addActivity(":/animations/chilling", Qt::Key_C);
#endif
cycle.start();
return app.exec();
}

View File

@ -2,13 +2,15 @@ HEADERS += stickman.h \
animation.h \
node.h \
lifecycle.h \
graphicsview.h
graphicsview.h \
rectbutton.h
SOURCES += main.cpp \
stickman.cpp \
animation.cpp \
node.cpp \
lifecycle.cpp \
graphicsview.cpp
graphicsview.cpp \
rectbutton.cpp
RESOURCES += stickman.qrc
@ -22,3 +24,4 @@ symbian {
TARGET.UID3 = 0xA000E3F9
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -1,5 +1,4 @@
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QT -= gui
@ -16,3 +15,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/complexpingpong
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example does not work on Symbian platform)
simulator: warning(This example does not work on Simulator platform)

View File

@ -1,5 +1,4 @@
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QT -= gui
@ -16,3 +15,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/complexpingpong
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example does not work on Symbian platform)
simulator: warning(This example does not work on Simulator platform)

View File

@ -1,5 +1,4 @@
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += qdbus
@ -19,3 +18,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/chat
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example does not work on Symbian platform)
simulator: warning(This example does not work on Simulator platform)

View File

@ -15,3 +15,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus
INSTALLS += sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example

View File

@ -1,5 +1,4 @@
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QT -= gui
@ -16,4 +15,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/listnames
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example does not work on Symbian platform)
simulator: warning(This example does not work on Simulator platform)

View File

@ -16,3 +16,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/pingpong
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example does not work on Symbian platform)
simulator: warning(This example does not work on Simulator platform)

View File

@ -16,3 +16,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/pingpong
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example does not work on Symbian platform)
simulator: warning(This example does not work on Simulator platform)

View File

@ -3,7 +3,6 @@
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += qdbus
@ -20,3 +19,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/remotecontrolledcar/car
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example does not work on Symbian platform)
simulator: warning(This example does not work on Simulator platform)

View File

@ -3,7 +3,6 @@
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += qdbus
@ -21,3 +20,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/remotecontrolledcar/controlle
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example does not work on Symbian platform)
simulator: warning(This example does not work on Simulator platform)

View File

@ -8,3 +8,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/remotecontrolledcar
INSTALLS += sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example

View File

@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/desktop
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example

View File

@ -9,3 +9,7 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/desktop/screenshot
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example might not fully work on Symbian platform)
maemo5: warning(This example might not fully work on Maemo platform)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -10,3 +10,7 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/classwizard
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example might not fully work on Symbian platform)
maemo5: warning(This example might not fully work on Maemo platform)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -14,3 +14,7 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
symbian: warning(This example might not fully work on Symbian platform)
maemo5: warning(This example might not fully work on Maemo platform)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -17,3 +17,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs
INSTALLS += sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example

View File

@ -9,3 +9,5 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/extension
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -63,9 +63,6 @@ FindDialog::FindDialog(QWidget *parent)
//! [0]
moreButton->setAutoDefault(false);
buttonBox = new QDialogButtonBox(Qt::Vertical);
buttonBox->addButton(findButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole);
//! [1]
//! [2]
@ -77,7 +74,42 @@ FindDialog::FindDialog(QWidget *parent)
//! [2]
//! [3]
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
// Create menu
QMenu *menu = new QMenu(this);
// Create Find menu item
menu->addAction(tr("Find"));
// Create More menu item
QAction *moreAction = menu->addAction(tr("More"));
moreAction->setCheckable(true);
// Create Options CBA
QAction *optionAction = new QAction(tr("Options"), this);
// Set defined menu into Options button
optionAction->setMenu(menu);
optionAction->setSoftKeyRole(QAction::PositiveSoftKey);
addAction(optionAction);
// Connect More menu item to setVisible slot
connect(moreAction, SIGNAL(triggered(bool)), extension, SLOT(setVisible(bool)));
// Create Exit CBA
QAction *backSoftKeyAction = new QAction(QString(tr("Exit")), this);
backSoftKeyAction->setSoftKeyRole(QAction::NegativeSoftKey);
// Exit button closes the application
connect(backSoftKeyAction, SIGNAL(triggered()), qApp, SLOT(quit()));
addAction(backSoftKeyAction);
#else
buttonBox = new QDialogButtonBox(Qt::Vertical);
buttonBox->addButton(findButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole);
connect(moreButton, SIGNAL(toggled(bool)), extension, SLOT(setVisible(bool)));
#endif
QVBoxLayout *extensionLayout = new QVBoxLayout;
extensionLayout->setMargin(0);
@ -96,13 +128,18 @@ FindDialog::FindDialog(QWidget *parent)
leftLayout->addLayout(topLeftLayout);
leftLayout->addWidget(caseCheckBox);
leftLayout->addWidget(fromStartCheckBox);
leftLayout->addStretch(1);
QGridLayout *mainLayout = new QGridLayout;
#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
#endif
mainLayout->addLayout(leftLayout, 0, 0);
#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_SIMULATOR)
mainLayout->addWidget(buttonBox, 0, 1);
#endif
mainLayout->addWidget(extension, 1, 0, 1, 2);
mainLayout->setRowStretch(2, 1);
setLayout(mainLayout);
setWindowTitle(tr("Extension"));

View File

@ -46,5 +46,12 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
FindDialog dialog;
return dialog.exec();
#ifdef Q_OS_SYMBIAN
dialog.showMaximized();
#else
dialog.show();
#endif
return app.exec();
}

View File

@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/findfiles
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example

View File

@ -46,6 +46,10 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Window window;
#ifdef Q_OS_SYMBIAN
window.showMaximized();
#else
window.show();
#endif
return app.exec();
}

View File

@ -44,7 +44,7 @@
//! [0]
Window::Window(QWidget *parent)
: QDialog(parent)
: QWidget(parent)
{
browseButton = createButton(tr("&Browse..."), SLOT(browse()));
findButton = createButton(tr("&Find"), SLOT(find()));
@ -62,11 +62,8 @@ Window::Window(QWidget *parent)
//! [0]
//! [1]
QHBoxLayout *buttonsLayout = new QHBoxLayout;
buttonsLayout->addStretch();
buttonsLayout->addWidget(findButton);
QGridLayout *mainLayout = new QGridLayout;
mainLayout->setSizeConstraint(QLayout::SetNoConstraint);
mainLayout->addWidget(fileLabel, 0, 0);
mainLayout->addWidget(fileComboBox, 0, 1, 1, 2);
mainLayout->addWidget(textLabel, 1, 0);
@ -75,12 +72,14 @@ Window::Window(QWidget *parent)
mainLayout->addWidget(directoryComboBox, 2, 1);
mainLayout->addWidget(browseButton, 2, 2);
mainLayout->addWidget(filesTable, 3, 0, 1, 3);
mainLayout->addWidget(filesFoundLabel, 4, 0, 1, 3);
mainLayout->addLayout(buttonsLayout, 5, 0, 1, 3);
mainLayout->addWidget(filesFoundLabel, 4, 0, 1, 2);
mainLayout->addWidget(findButton, 4, 2);
setLayout(mainLayout);
setWindowTitle(tr("Find Files"));
#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
resize(700, 300);
#endif
}
//! [1]
@ -194,7 +193,12 @@ void Window::showFiles(const QStringList &files)
filesTable->setItem(row, 1, sizeItem);
}
filesFoundLabel->setText(tr("%1 file(s) found").arg(files.size()) +
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
(" (Select file to open it)"));
#else
(" (Double click on a file to open it)"));
#endif
filesFoundLabel->setWordWrap(true);
}
//! [8]
@ -214,6 +218,9 @@ QComboBox *Window::createComboBox(const QString &text)
comboBox->setEditable(true);
comboBox->addItem(text);
comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
comboBox->setMinimumContentsLength(3);
#endif
return comboBox;
}
//! [10]
@ -225,7 +232,7 @@ void Window::createFilesTable()
filesTable->setSelectionBehavior(QAbstractItemView::SelectRows);
QStringList labels;
labels << tr("File Name") << tr("Size");
labels << tr("Filename") << tr("Size");
filesTable->setHorizontalHeaderLabels(labels);
filesTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
filesTable->verticalHeader()->hide();

View File

@ -41,7 +41,7 @@
#ifndef WINDOW_H
#define WINDOW_H
#include <QDialog>
#include <QWidget>
#include <QDir>
QT_BEGIN_NAMESPACE
@ -53,7 +53,7 @@ class QTableWidgetItem;
QT_END_NAMESPACE
//! [0]
class Window : public QDialog
class Window : public QWidget
{
Q_OBJECT

View File

@ -10,3 +10,7 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/licensewizard
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example might not fully work on Symbian platform)
maemo5: warning(This example might not fully work on Maemo platform)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -11,4 +11,7 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
symbian: warning(This example might not fully work on Symbian platform)
maemo5: warning(This example might not fully work on Maemo platform)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -49,7 +49,7 @@
"will activate the detected escape button (if any).")
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
: QWidget(parent)
{
errorMessageDialog = new QErrorMessage(this);
@ -149,6 +149,7 @@ Dialog::Dialog(QWidget *parent)
native = new QCheckBox(this);
native->setText("Use native file dialog.");
native->setChecked(true);
QGridLayout *layout = new QGridLayout;
layout->setColumnStretch(1, 1);
layout->setColumnMinimumWidth(1, 250);
@ -183,7 +184,19 @@ Dialog::Dialog(QWidget *parent)
layout->addWidget(errorButton, 14, 0);
layout->addWidget(errorLabel, 14, 1);
layout->addWidget(native, 15, 0);
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
QWidget *widget = new QWidget;
widget->setLayout(layout);
QScrollArea *scrollArea = new QScrollArea(this);
scrollArea->setWidget(widget);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(scrollArea);
setLayout(mainLayout);
#else
setLayout(layout);
#endif
setWindowTitle(tr("Standard Dialogs"));
}

View File

@ -41,7 +41,7 @@
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QCheckBox;
@ -49,7 +49,7 @@ class QLabel;
class QErrorMessage;
QT_END_NAMESPACE
class Dialog : public QDialog
class Dialog : public QWidget
{
Q_OBJECT

View File

@ -56,5 +56,11 @@ int main(int argc, char *argv[])
app.installTranslator(translator);
Dialog dialog;
return dialog.exec();
#ifdef Q_OS_SYMBIAN
dialog.showMaximized();
#else
dialog.show();
#endif
return app.exec();
}

View File

@ -11,3 +11,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -53,5 +53,11 @@ int main(int argc, char *argv[])
fileName = ".";
TabDialog tabdialog(fileName);
return tabdialog.exec();
#ifdef Q_OS_SYMBIAN
tabdialog.showMaximized();
#else
tabdialog.show();
#endif
return app.exec();
}

View File

@ -65,6 +65,7 @@ TabDialog::TabDialog(const QString &fileName, QWidget *parent)
//! [4]
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setSizeConstraint(QLayout::SetNoConstraint);
mainLayout->addWidget(tabWidget);
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);

View File

@ -10,3 +10,6 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
symbian: warning(This example might not fully work on Symbian platform)
maemo5: warning(This example might not fully work on Maemo platform)

View File

@ -128,7 +128,11 @@ int main(int argc, char *argv[])
wizard.addPage(createConclusionPage());
wizard.setWindowTitle("Trivial Wizard");
#ifdef Q_OS_SYMBIAN
wizard.showMaximized();
#else
wizard.show();
#endif
return app.exec();
}

View File

@ -7,3 +7,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/trivialwizard
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example might not fully work on Symbian platform)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -13,3 +13,4 @@ symbian {
TARGET.UID3 = 0xA000C615
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -46,25 +46,28 @@
DragWidget::DragWidget(QWidget *parent)
: QFrame(parent)
{
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
#else
setMinimumSize(200, 200);
#endif
setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
setAcceptDrops(true);
QLabel *boatIcon = new QLabel(this);
boatIcon->setPixmap(QPixmap(":/images/boat.png"));
boatIcon->move(20, 20);
boatIcon->move(10, 10);
boatIcon->show();
boatIcon->setAttribute(Qt::WA_DeleteOnClose);
QLabel *carIcon = new QLabel(this);
carIcon->setPixmap(QPixmap(":/images/car.png"));
carIcon->move(120, 20);
carIcon->move(100, 10);
carIcon->show();
carIcon->setAttribute(Qt::WA_DeleteOnClose);
QLabel *houseIcon = new QLabel(this);
houseIcon->setPixmap(QPixmap(":/images/house.png"));
houseIcon->move(20, 120);
houseIcon->move(10, 80);
houseIcon->show();
houseIcon->setAttribute(Qt::WA_DeleteOnClose);
}

View File

@ -55,7 +55,11 @@ int main(int argc, char *argv[])
mainWidget.setLayout(horizontalLayout);
mainWidget.setWindowTitle(QObject::tr("Draggable Icons"));
#ifdef Q_OS_SYMBIAN
mainWidget.showMaximized();
#else
mainWidget.show();
#endif
return app.exec();
}

View File

@ -15,3 +15,5 @@ symbian {
TARGET.UID3 = 0xA000CF64
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -62,16 +62,18 @@ DragWidget::DragWidget(QWidget *parent)
wordLabel->show();
wordLabel->setAttribute(Qt::WA_DeleteOnClose);
x += wordLabel->width() + 2;
if (x >= 195) {
if (x >= 245) {
x = 5;
y += wordLabel->height() + 2;
}
}
}
/*
QPalette newPalette = palette();
newPalette.setColor(QPalette::Window, Qt::white);
setPalette(newPalette);
*/
setAcceptDrops(true);
setMinimumSize(400, qMax(200, y));

View File

@ -47,6 +47,10 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
DragWidget window;
#ifdef Q_OS_SYMBIAN
window.showMaximized();
#else
window.show();
#endif
return app.exec();
}

View File

@ -11,3 +11,7 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/dropsite
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example might not fully work on Symbian platform)
maemo5: warning(This example might not fully work on Maemo platform)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -65,7 +65,11 @@ DragWidget::DragWidget(QWidget *parent)
wordLabel->show();
wordLabel->setAttribute(Qt::WA_DeleteOnClose);
x += wordLabel->width() + 2;
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
if (x >= 345) {
#else
if (x >= 245) {
#endif
x = 5;
y += wordLabel->height() + 2;
}

View File

@ -16,4 +16,4 @@ symbian {
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -51,10 +51,15 @@ int main(int argc, char *argv[])
#endif
DragWidget window;
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
window.showMaximized();
#else
bool smallScreen = QApplication::arguments().contains("-small-screen");
if (smallScreen)
window.showFullScreen();
else
window.show();
#endif
return app.exec();
}

View File

@ -49,6 +49,10 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
MainWindow window;
window.openImage(":/images/example.jpg");
#ifdef Q_OS_SYMBIAN
window.showMaximized();
#else
window.show();
#endif
return app.exec();
}

View File

@ -90,14 +90,15 @@ void MainWindow::setupPuzzle()
{
int size = qMin(puzzleImage.width(), puzzleImage.height());
puzzleImage = puzzleImage.copy((puzzleImage.width() - size)/2,
(puzzleImage.height() - size)/2, size, size).scaled(400,
400, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
(puzzleImage.height() - size)/2, size, size).scaled(puzzleWidget->width(),
puzzleWidget->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
piecesList->clear();
for (int y = 0; y < 5; ++y) {
for (int x = 0; x < 5; ++x) {
QPixmap pieceImage = puzzleImage.copy(x*80, y*80, 80, 80);
int pieceSize = puzzleWidget->pieceSize();
QPixmap pieceImage = puzzleImage.copy(x * pieceSize, y * pieceSize, pieceSize, pieceSize);
piecesList->addPiece(pieceImage, QPoint(x, y));
}
}
@ -137,9 +138,14 @@ void MainWindow::setupWidgets()
{
QFrame *frame = new QFrame;
QHBoxLayout *frameLayout = new QHBoxLayout(frame);
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
puzzleWidget = new PuzzleWidget(260);
#else
puzzleWidget = new PuzzleWidget(400);
#endif
piecesList = new PiecesList(puzzleWidget->pieceSize(), this);
piecesList = new PiecesList;
puzzleWidget = new PuzzleWidget;
connect(puzzleWidget, SIGNAL(puzzleCompleted()),
this, SLOT(setCompleted()), Qt::QueuedConnection);

View File

@ -42,12 +42,12 @@
#include "pieceslist.h"
PiecesList::PiecesList(QWidget *parent)
: QListWidget(parent)
PiecesList::PiecesList(int pieceSize, QWidget *parent)
: QListWidget(parent), m_PieceSize(pieceSize)
{
setDragEnabled(true);
setViewMode(QListView::IconMode);
setIconSize(QSize(60, 60));
setIconSize(QSize(m_PieceSize, m_PieceSize));
setSpacing(10);
setAcceptDrops(true);
setDropIndicatorShown(true);

View File

@ -48,7 +48,7 @@ class PiecesList : public QListWidget
Q_OBJECT
public:
PiecesList(QWidget *parent = 0);
PiecesList(int pieceSize, QWidget *parent = 0);
void addPiece(QPixmap pixmap, QPoint location);
protected:
@ -56,6 +56,8 @@ protected:
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
void startDrag(Qt::DropActions supportedActions);
int m_PieceSize;
};
#endif

View File

@ -27,3 +27,4 @@ wince*: {
addFile.path = .
DEPLOYMENT += addFile
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -42,12 +42,12 @@
#include "puzzlewidget.h"
PuzzleWidget::PuzzleWidget(QWidget *parent)
: QWidget(parent)
PuzzleWidget::PuzzleWidget(int imageSize, QWidget *parent)
: QWidget(parent), m_ImageSize(imageSize)
{
setAcceptDrops(true);
setMinimumSize(400, 400);
setMaximumSize(400, 400);
setMinimumSize(m_ImageSize, m_ImageSize);
setMaximumSize(m_ImageSize, m_ImageSize);
}
void PuzzleWidget::clear()
@ -116,7 +116,7 @@ void PuzzleWidget::dropEvent(QDropEvent *event)
event->setDropAction(Qt::MoveAction);
event->accept();
if (location == QPoint(square.x()/80, square.y()/80)) {
if (location == QPoint(square.x()/pieceSize(), square.y()/pieceSize())) {
inPlace++;
if (inPlace == 25)
emit puzzleCompleted();
@ -151,7 +151,7 @@ void PuzzleWidget::mousePressEvent(QMouseEvent *event)
piecePixmaps.removeAt(found);
pieceRects.removeAt(found);
if (location == QPoint(square.x()/80, square.y()/80))
if (location == QPoint(square.x()/pieceSize(), square.y()/pieceSize()))
inPlace--;
update(square);
@ -175,7 +175,7 @@ void PuzzleWidget::mousePressEvent(QMouseEvent *event)
pieceRects.insert(found, square);
update(targetSquare(event->pos()));
if (location == QPoint(square.x()/80, square.y()/80))
if (location == QPoint(square.x()/pieceSize(), square.y()/pieceSize()))
inPlace++;
}
}
@ -200,5 +200,15 @@ void PuzzleWidget::paintEvent(QPaintEvent *event)
const QRect PuzzleWidget::targetSquare(const QPoint &position) const
{
return QRect(position.x()/80 * 80, position.y()/80 * 80, 80, 80);
return QRect(position.x()/pieceSize() * pieceSize(), position.y()/pieceSize() * pieceSize(), pieceSize(), pieceSize());
}
int PuzzleWidget::pieceSize() const
{
return m_ImageSize / 5;
}
int PuzzleWidget::imageSize() const
{
return m_ImageSize;
}

View File

@ -57,9 +57,12 @@ class PuzzleWidget : public QWidget
Q_OBJECT
public:
PuzzleWidget(QWidget *parent = 0);
PuzzleWidget(int imageSize, QWidget *parent = 0);
void clear();
int pieceSize() const;
int imageSize() const;
signals:
void puzzleCompleted();
@ -80,6 +83,7 @@ private:
QList<QPoint> pieceLocations;
QRect highlightedRect;
int inPlace;
int m_ImageSize;
};
#endif

View File

@ -131,8 +131,34 @@ void BlurPicker::keyPressEvent(QKeyEvent *event)
break;
}
if (m_animation.state() == QAbstractAnimation::Stopped && delta) {
m_animation.setEndValue(m_index + delta);
m_animation.start();
event->accept();
m_animation.setEndValue(m_index + delta);
m_animation.start();
event->accept();
}
}
void BlurPicker::resizeEvent(QResizeEvent */*event*/)
{
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
fitInView(sceneRect(), Qt::KeepAspectRatio);
#endif
}
void BlurPicker::mousePressEvent(QMouseEvent *event)
{
int delta = 0;
if(event->x() > (width() / 2))
{
delta = 1;
}
else
{
delta = -1;
}
if (m_animation.state() == QAbstractAnimation::Stopped && delta) {
m_animation.setEndValue(m_index + delta);
m_animation.start();
event->accept();
}
}

View File

@ -60,6 +60,8 @@ public:
protected:
void keyPressEvent(QKeyEvent *event);
void resizeEvent(QResizeEvent *event);
void mousePressEvent(QMouseEvent *event);
private:
void setupScene();

View File

@ -7,3 +7,6 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/blurpicker
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS blurpicker.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/blurpicker
INSTALLS += target sources
symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -47,8 +47,13 @@ int main(int argc, char **argv)
BlurPicker blurPicker;
blurPicker.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Application Picker"));
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
blurPicker.showMaximized();
#else
blurPicker.setFixedSize(400, 300);
blurPicker.show();
#endif
return app.exec();
}

View File

@ -56,7 +56,6 @@ FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent)
m_animation->setStartValue(0);
m_animation->setEndValue(1);
setRenderHint(QPainter::Antialiasing, true);
setFrameStyle(QFrame::NoFrame);
}
@ -75,7 +74,7 @@ void FadeMessage::togglePopup()
void FadeMessage::setupScene()
{
QGraphicsRectItem *parent = m_scene.addRect(0, 0, 400, 600);
QGraphicsRectItem *parent = m_scene.addRect(0, 0, 800, 600);
parent->setPen(Qt::NoPen);
parent->setZValue(0);
@ -85,7 +84,7 @@ void FadeMessage::setupScene()
for (int i = 1; i < 5; ++i)
for (int j = 2; j < 5; ++j) {
QGraphicsRectItem *item = m_scene.addRect(i * 50, j * 50, 38, 38);
QGraphicsRectItem *item = m_scene.addRect(i * 50, (j - 1) * 50, 38, 38);
item->setParentItem(parent);
item->setZValue(1);
int hue = 12 * (i * 5 + j);
@ -124,6 +123,10 @@ void FadeMessage::setupScene()
press->setText(tr("Press me"));
connect(press, SIGNAL(clicked()), SLOT(togglePopup()));
m_scene.addWidget(press);
press->move(300, 500);
}
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
press->move(200, 210);
#else
press->move(300, 500);
#endif
}

View File

@ -12,5 +12,7 @@ sources.files = $$SOURCES \
fademessage.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/fademessage
DEPLOYMENT_PLUGIN += qjpeg
symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -48,8 +48,12 @@ int main(int argc, char **argv)
FadeMessage widget;
widget.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Popup Message with Effect"));
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
widget.showMaximized();
#else
widget.setFixedSize(400, 600);
widget.show();
#endif
return app.exec();
}

View File

@ -134,3 +134,9 @@ void Lighting::animate()
m_scene.update();
}
void Lighting::resizeEvent(QResizeEvent */*event*/)
{
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
fitInView(sceneRect(), Qt::KeepAspectRatio);
#endif
}

View File

@ -57,6 +57,9 @@ private slots:
private:
void setupScene();
protected:
void resizeEvent(QResizeEvent *event);
private:
qreal angle;
QGraphicsScene m_scene;

View File

@ -6,3 +6,7 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/lighting
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS lighting.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/lighting
INSTALLS += target sources
symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)

View File

@ -47,8 +47,13 @@ int main(int argc, char **argv)
Lighting lighting;
lighting.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Lighting and Shadows"));
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
lighting.showMaximized();
#else
lighting.resize(640, 480);
lighting.show();
#endif
return app.exec();
}

View File

@ -62,3 +62,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]
INSTALLS += sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example

View File

@ -19,3 +19,7 @@ symbian {
TARGET.UID3 = 0xA000D7D0
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
symbian: warning(This example does not work on Symbian platform)
maemo5: warning(This example does not work on Maemo platform)
simulator: warning(This example does not work on Simulator platform)

View File

@ -7,3 +7,8 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/anchorlayout
INSTALLS += target sources
TARGET = anchorlayout
symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -122,7 +122,12 @@ int main(int argc, char **argv)
scene.addItem(w);
scene.setBackgroundBrush(Qt::darkGreen);
QGraphicsView view(&scene);
#if defined(Q_WS_S60)
view.showMaximized();
#else
view.show();
#endif
return app.exec();
}

View File

@ -15,3 +15,5 @@ symbian {
TARGET.UID3 = 0xA000A645
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -51,8 +51,12 @@ int main(int argc, char **argv)
Window *window = new Window;
scene.addItem(window);
QGraphicsView view(&scene);
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
view.showMaximized();
#else
view.resize(600, 600);
view.show();
#endif
return app.exec();
}

View File

@ -17,3 +17,5 @@ symbian {
TARGET.UID3 = 0xA000A643
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -79,8 +79,12 @@ int main(int argc, char **argv)
view.setDragMode(QGraphicsView::ScrollHandDrag);
//! [5] //! [6]
view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice"));
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
view.showMaximized();
#else
view.resize(400, 300);
view.show();
#endif
QTimer timer;
QObject::connect(&timer, SIGNAL(timeout()), &scene, SLOT(advance()));

View File

@ -19,4 +19,8 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/diagramscene
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
symbian: warning(This example might not fully work on Symbian platform)
maemo5: warning(This example might not fully work on Maemo platform)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -18,3 +18,6 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/dragdroprobot
INSTALLS += target sources
symbian: CONFIG += qt_example
maemo5: CONFIG += qt_example
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -45,6 +45,22 @@
#include <math.h>
class GraphicsView : public QGraphicsView
{
public:
GraphicsView(QGraphicsScene *scene) : QGraphicsView(scene)
{
}
protected:
virtual void resizeEvent(QResizeEvent *event)
{
#if defined(Q_OS_SYMBIAN)
fitInView(sceneRect(), Qt::KeepAspectRatio);
#endif
}
};
//! [0]
int main(int argc, char **argv)
{
@ -69,12 +85,16 @@ int main(int argc, char **argv)
scene.addItem(robot);
//! [1]
//! [2]
QGraphicsView view(&scene);
GraphicsView view(&scene);
view.setRenderHint(QPainter::Antialiasing);
view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
view.setBackgroundBrush(QColor(230, 200, 167));
view.setWindowTitle("Drag and Drop Robot");
view.show();
#if defined(Q_OS_SYMBIAN)
view.showMaximized();
#else
view.show();
#endif
return app.exec();
}

View File

@ -144,6 +144,6 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
painter->setBrush(Qt::black);
painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2);
painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
}
//! [6]

View File

@ -21,3 +21,6 @@ symbian {
TARGET.UID3 = 0xA000A642
CONFIG += qt_example
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
simulator: warning(This example might not fully work on Simulator platform)

View File

@ -132,17 +132,14 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
centerNode->moveBy(20, 0);
break;
case Qt::Key_Plus:
scaleView(qreal(1.2));
zoomIn();
break;
case Qt::Key_Minus:
scaleView(1 / qreal(1.2));
zoomOut();
break;
case Qt::Key_Space:
case Qt::Key_Enter:
foreach (QGraphicsItem *item, scene()->items()) {
if (qgraphicsitem_cast<Node *>(item))
item->setPos(-150 + qrand() % 300, -150 + qrand() % 300);
}
shuffle();
break;
default:
QGraphicsView::keyPressEvent(event);
@ -206,6 +203,7 @@ void GraphWidget::drawBackground(QPainter *painter, const QRectF &rect)
painter->setBrush(Qt::NoBrush);
painter->drawRect(sceneRect);
#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5)
// Text
QRectF textRect(sceneRect.left() + 4, sceneRect.top() + 4,
sceneRect.width() - 4, sceneRect.height() - 4);
@ -220,6 +218,7 @@ void GraphWidget::drawBackground(QPainter *painter, const QRectF &rect)
painter->drawText(textRect.translated(2, 2), message);
painter->setPen(Qt::black);
painter->drawText(textRect, message);
#endif
}
//! [6]
@ -233,3 +232,21 @@ void GraphWidget::scaleView(qreal scaleFactor)
scale(scaleFactor, scaleFactor);
}
//! [7]
void GraphWidget::shuffle()
{
foreach (QGraphicsItem *item, scene()->items()) {
if (qgraphicsitem_cast<Node *>(item))
item->setPos(-150 + qrand() % 300, -150 + qrand() % 300);
}
}
void GraphWidget::zoomIn()
{
scaleView(qreal(1.2));
}
void GraphWidget::zoomOut()
{
scaleView(1 / qreal(1.2));
}

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