diff options
author | João Abecasis <joao@abecasis.name> | 2009-11-05 15:18:52 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-11-05 15:18:52 (GMT) |
commit | ad3e723c334d72b746979b284910ac9b698b2d0b (patch) | |
tree | 28fa320fcbd38938345f30817d75f19716c4e534 /examples | |
parent | c4d8d7fd35c8ac7fd2c14208e5e7ca0a35c101e1 (diff) | |
parent | 4cd683231190443e5243f66098c7322e3808a131 (diff) | |
download | Qt-ad3e723c334d72b746979b284910ac9b698b2d0b.zip Qt-ad3e723c334d72b746979b284910ac9b698b2d0b.tar.gz Qt-ad3e723c334d72b746979b284910ac9b698b2d0b.tar.bz2 |
Merge commit 'origin/4.6' into large-file-support
Diffstat (limited to 'examples')
19 files changed, 182 insertions, 71 deletions
diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp index 250fb85..1b6f9cd 100644 --- a/examples/animation/stickman/lifecycle.cpp +++ b/examples/animation/stickman/lifecycle.cpp @@ -194,14 +194,14 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa topLevel->setInitialState(frameState); else //! [2] - previousState->addTransition(previousState, SIGNAL(polished()), frameState); + previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), frameState); //! [2] previousState = frameState; } // Loop - previousState->addTransition(previousState, SIGNAL(polished()), topLevel->initialState()); + previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), topLevel->initialState()); return topLevel; diff --git a/examples/gestures/imagegestures/imagegestures.pro b/examples/gestures/imagegestures/imagegestures.pro index 7780ad9..8c947e4 100644 --- a/examples/gestures/imagegestures/imagegestures.pro +++ b/examples/gestures/imagegestures/imagegestures.pro @@ -5,12 +5,12 @@ SOURCES = imagewidget.cpp \ mainwidget.cpp # install -target.path = $$[QT_INSTALL_EXAMPLES]/gestures/imageviewer +target.path = $$[QT_INSTALL_EXAMPLES]/gestures/imagegestures sources.files = $$SOURCES \ $$HEADERS \ $$RESOURCES \ $$FORMS \ - imageviewer.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/gestures/imageviewer + imagegestures.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/gestures/imagegestures INSTALLS += target \ sources diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp index 95525c5..f615129 100644 --- a/examples/gestures/imagegestures/imagewidget.cpp +++ b/examples/gestures/imagegestures/imagewidget.cpp @@ -102,17 +102,13 @@ void ImageWidget::mouseDoubleClickEvent(QMouseEvent *) //! [gesture event handler] bool ImageWidget::gestureEvent(QGestureEvent *event) { - if (QGesture *pan = event->gesture(Qt::PanGesture)) { - panTriggered(static_cast<QPanGesture*>(pan)); - return true; - } else if (QGesture *pinch = event->gesture(Qt::PinchGesture)) { - pinchTriggered(static_cast<QPinchGesture*>(pinch)); - return true; - } else if (QGesture *swipe = event->gesture(Qt::SwipeGesture)) { - swipeTriggered(static_cast<QSwipeGesture*>(swipe)); - return true; - } - return false; + if (QGesture *pan = event->gesture(Qt::PanGesture)) + panTriggered(static_cast<QPanGesture *>(pan)); + if (QGesture *pinch = event->gesture(Qt::PinchGesture)) + pinchTriggered(static_cast<QPinchGesture *>(pinch)); + if (QGesture *swipe = event->gesture(Qt::SwipeGesture)) + swipeTriggered(static_cast<QSwipeGesture *>(swipe)); + return true; } //! [gesture event handler] @@ -128,21 +124,21 @@ void ImageWidget::panTriggered(QPanGesture *gesture) setCursor(Qt::ArrowCursor); } #endif - QSizeF lastOffset = gesture->offset(); - horizontalOffset += lastOffset.width(); - verticalOffset += lastOffset.height(); + QPointF delta = gesture->delta(); + horizontalOffset += delta.x(); + verticalOffset += delta.y(); update(); } void ImageWidget::pinchTriggered(QPinchGesture *gesture) { - QPinchGesture::WhatChanged whatChanged = gesture->whatChanged(); - if (whatChanged & QPinchGesture::RotationAngleChanged) { + QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags(); + if (changeFlags & QPinchGesture::RotationAngleChanged) { qreal value = gesture->property("rotationAngle").toReal(); qreal lastValue = gesture->property("lastRotationAngle").toReal(); rotationAngle += value - lastValue; } - if (whatChanged & QPinchGesture::ScaleFactorChanged) { + if (changeFlags & QPinchGesture::ScaleFactorChanged) { qreal value = gesture->property("scaleFactor").toReal(); qreal lastValue = gesture->property("lastScaleFactor").toReal(); scaleFactor += value - lastValue; diff --git a/examples/graphicsview/anchorlayout/anchorlayout.pro b/examples/graphicsview/anchorlayout/anchorlayout.pro index c2a1bea..fd085cc 100644 --- a/examples/graphicsview/anchorlayout/anchorlayout.pro +++ b/examples/graphicsview/anchorlayout/anchorlayout.pro @@ -1,9 +1,4 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Tue May 12 15:22:25 2009 -###################################################################### - -# Input -SOURCES += main.cpp +SOURCES = main.cpp # install target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/anchorlayout @@ -11,5 +6,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES anchorlayout.pro sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/anchorlayout INSTALLS += target sources -TARGET = anchorlayout_example -CONFIG+=console
\ No newline at end of file +TARGET = anchorlayout diff --git a/examples/graphicsview/simpleanchorlayout/main.cpp b/examples/graphicsview/simpleanchorlayout/main.cpp new file mode 100644 index 0000000..493b00f --- /dev/null +++ b/examples/graphicsview/simpleanchorlayout/main.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +class Widget : public QGraphicsWidget +{ +public: + Widget(const QColor &color, const QColor &textColor, const QString &caption, + QGraphicsItem *parent = 0) + : QGraphicsWidget(parent), caption(caption), color(color), textColor(textColor) + { + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) + { + QFont font; + font.setPixelSize(0.75 * qMin(boundingRect().width(), boundingRect().height())); + + painter->fillRect(boundingRect(), color); + painter->save(); + painter->setFont(font); + painter->setPen(textColor); + painter->drawText(boundingRect(), Qt::AlignCenter, caption); + painter->restore(); + } + +private: + QString caption; + QColor color; + QColor textColor; +}; + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QGraphicsScene *scene = new QGraphicsScene(); + + Widget *a = new Widget(Qt::blue, Qt::white, "a"); + a->setPreferredSize(100, 100); + Widget *b = new Widget(Qt::green, Qt::black, "b"); + b->setPreferredSize(100, 100); + Widget *c = new Widget(Qt::red, Qt::black, "c"); + c->setPreferredSize(100, 100); + + QGraphicsAnchorLayout *layout = new QGraphicsAnchorLayout(); +/* + //! [adding a corner anchor in two steps] + layout->addAnchor(a, Qt::AnchorTop, layout, Qt::AnchorTop); + layout->addAnchor(a, Qt::AnchorLeft, layout, Qt::AnchorLeft); + //! [adding a corner anchor in two steps] +*/ + //! [adding a corner anchor] + layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner); + //! [adding a corner anchor] + + //! [adding anchors] + layout->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight); + layout->addAnchor(b, Qt::AnchorTop, a, Qt::AnchorBottom); + //! [adding anchors] + + // Place a third widget below the second. + layout->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); + +/* + //! [adding anchors to match sizes in two steps] + layout->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); + layout->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight); + //! [adding anchors to match sizes in two steps] +*/ + + //! [adding anchors to match sizes] + layout->addAnchors(b, c, Qt::Horizontal); + //! [adding anchors to match sizes] + + // Anchor the bottom-right corner of the third widget to the bottom-right + // corner of the layout. + layout->addCornerAnchors(c, Qt::BottomRightCorner, layout, Qt::BottomRightCorner); + + QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint); + w->setPos(20, 20); + w->setMinimumSize(100, 100); + w->setPreferredSize(320, 240); + w->setLayout(layout); + w->setWindowTitle(QApplication::translate("simpleanchorlayout", "QGraphicsAnchorLayout in use")); + scene->addItem(w); + + QGraphicsView *view = new QGraphicsView(); + view->setScene(scene); + view->setWindowTitle(QApplication::translate("simpleanchorlayout", "Simple Anchor Layout")); + view->resize(360, 320); + view->show(); + + return app.exec(); +} diff --git a/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro b/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro new file mode 100644 index 0000000..e1c7aeb --- /dev/null +++ b/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro @@ -0,0 +1,9 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/simpleanchorlayout +sources.files = $$SOURCES $$HEADERS $$RESOURCES simpleanchorlayout.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/simpleanchorlayout +INSTALLS += target sources + +TARGET = simpleanchorlayout diff --git a/examples/mainwindows/mdi/mainwindow.cpp b/examples/mainwindows/mdi/mainwindow.cpp index 712d91f..edb33b7 100644 --- a/examples/mainwindows/mdi/mainwindow.cpp +++ b/examples/mainwindows/mdi/mainwindow.cpp @@ -71,7 +71,7 @@ MainWindow::MainWindow() void MainWindow::closeEvent(QCloseEvent *event) { mdiArea->closeAllSubWindows(); - if (activeMdiChild()) { + if (mdiArea->currentSubWindow()) { event->ignore(); } else { writeSettings(); diff --git a/examples/mainwindows/sdi/mainwindow.h b/examples/mainwindows/sdi/mainwindow.h index ca478df..a925e2f 100644 --- a/examples/mainwindows/sdi/mainwindow.h +++ b/examples/mainwindows/sdi/mainwindow.h @@ -50,12 +50,14 @@ class QMenu; class QTextEdit; QT_END_NAMESPACE +//! [class definition with macro] class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(); +//! [class definition with macro] MainWindow(const QString &fileName); protected: diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 05723ae..3d537a2 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -216,7 +216,7 @@ InputTest::~InputTest() {} void InputTest::status() { - qWarning()<<"bytesReady = "<<audioInput->bytesReady()<<" bytes, clock = "<<audioInput->clock()<<"ms, totalTime = "<<audioInput->totalTime()/1000<<"ms"; + qWarning()<<"bytesReady = "<<audioInput->bytesReady()<<" bytes, clock = "<<audioInput->clock()/1000<<"ms, totalTime = "<<audioInput->totalTime()/1000<<"ms"; } void InputTest::readMore() diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index 9e532cd..c92bbaf 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -200,7 +200,7 @@ void AudioTest::deviceChanged(int idx) void AudioTest::status() { - qWarning()<<"byteFree = "<<audioOutput->bytesFree()<<" bytes, clock = "<<audioOutput->clock()<<"ms, totalTime = "<<audioOutput->totalTime()/1000<<"ms"; + qWarning()<<"byteFree = "<<audioOutput->bytesFree()<<" bytes, clock = "<<audioOutput->clock()/1000<<"ms, totalTime = "<<audioOutput->totalTime()/1000<<"ms"; } void AudioTest::writeMore() diff --git a/examples/multimedia/videographicsitem/videoitem.cpp b/examples/multimedia/videographicsitem/videoitem.cpp index c95e335..99e8df8 100644 --- a/examples/multimedia/videographicsitem/videoitem.cpp +++ b/examples/multimedia/videographicsitem/videoitem.cpp @@ -104,7 +104,7 @@ QList<QVideoFrame::PixelFormat> VideoItem::supportedPixelFormats( bool VideoItem::start(const QVideoSurfaceFormat &format) { if (isFormatSupported(format)) { - imageFormat = QVideoFrame::equivalentImageFormat(format.pixelFormat()); + imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); imageSize = format.frameSize(); framePainted = true; @@ -129,7 +129,7 @@ void VideoItem::stop() bool VideoItem::present(const QVideoFrame &frame) { if (!framePainted) { - if (!isStarted()) + if (!QAbstractVideoSurface::isActive()) setError(StoppedError); return false; diff --git a/examples/multimedia/videographicsitem/videoplayer.cpp b/examples/multimedia/videographicsitem/videoplayer.cpp index 83644db..9ac4152 100644 --- a/examples/multimedia/videographicsitem/videoplayer.cpp +++ b/examples/multimedia/videographicsitem/videoplayer.cpp @@ -119,8 +119,7 @@ void VideoPlayer::openFile() QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie")); if (!fileName.isEmpty()) { - if (videoItem->isStarted()) - videoItem->stop(); + videoItem->stop(); movie.setFileName(fileName); diff --git a/examples/multimedia/videowidget/videoplayer.cpp b/examples/multimedia/videowidget/videoplayer.cpp index ed24714..cd146e8 100644 --- a/examples/multimedia/videowidget/videoplayer.cpp +++ b/examples/multimedia/videowidget/videoplayer.cpp @@ -100,8 +100,7 @@ void VideoPlayer::openFile() QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie")); if (!fileName.isEmpty()) { - if (surface->isStarted()) - surface->stop(); + surface->stop(); movie.setFileName(fileName); diff --git a/examples/multimedia/videowidget/videowidget.cpp b/examples/multimedia/videowidget/videowidget.cpp index 80688e1..f73a52f 100644 --- a/examples/multimedia/videowidget/videowidget.cpp +++ b/examples/multimedia/videowidget/videowidget.cpp @@ -84,7 +84,7 @@ void VideoWidget::paintEvent(QPaintEvent *event) { QPainter painter(this); - if (surface->isStarted()) { + if (surface->isActive()) { const QRect videoRect = surface->videoRect(); if (!videoRect.contains(event->rect())) { diff --git a/examples/multimedia/videowidget/videowidgetsurface.cpp b/examples/multimedia/videowidget/videowidgetsurface.cpp index ec9b8b5..b69375c 100644 --- a/examples/multimedia/videowidget/videowidgetsurface.cpp +++ b/examples/multimedia/videowidget/videowidgetsurface.cpp @@ -73,7 +73,7 @@ bool VideoWidgetSurface::isFormatSupported( { Q_UNUSED(similar); - const QImage::Format imageFormat = QVideoFrame::equivalentImageFormat(format.pixelFormat()); + const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); const QSize size = format.frameSize(); return imageFormat != QImage::Format_Invalid @@ -85,7 +85,7 @@ bool VideoWidgetSurface::isFormatSupported( //! [2] bool VideoWidgetSurface::start(const QVideoSurfaceFormat &format) { - const QImage::Format imageFormat = QVideoFrame::equivalentImageFormat(format.pixelFormat()); + const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); const QSize size = format.frameSize(); if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) { diff --git a/examples/network/qftp/sym_iap_util.h b/examples/network/qftp/sym_iap_util.h index ebeae0a..9b4128c 100644 --- a/examples/network/qftp/sym_iap_util.h +++ b/examples/network/qftp/sym_iap_util.h @@ -501,10 +501,14 @@ static void qt_SetDefaultIapL() static int qt_SetDefaultIap() { +#ifndef __WINS__ TRAPD(err1, qt_SetDefaultIapL()); // TRAPD(err2, qt_InterfaceInfoL()); // TRAPD(err3, qt_RouteInfoL()); return err1; +#else + return 0; // IAP dialog not required for emulator +#endif } #endif // QSYM_IAP_UTIL_H diff --git a/examples/opengl/hellogl_es/hellogl_es.pro b/examples/opengl/hellogl_es/hellogl_es.pro index 3168743..80ef7df 100644 --- a/examples/opengl/hellogl_es/hellogl_es.pro +++ b/examples/opengl/hellogl_es/hellogl_es.pro @@ -20,15 +20,6 @@ HEADERS += bubble.h RESOURCES += texture.qrc QT += opengl -wince*:{ - contains(QT_CONFIG,opengles1) { - QMAKE_LIBS += "libGLES_CM.lib" - } - contains(QT_CONFIG,opengles1cl) { - QMAKE_LIBS += "libGLES_CL.lib" - } -} - # install target.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl_es sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hellogl_es.pro diff --git a/examples/opengl/hellogl_es2/hellogl_es2.pro b/examples/opengl/hellogl_es2/hellogl_es2.pro index d5ad4b8..92b4224 100644 --- a/examples/opengl/hellogl_es2/hellogl_es2.pro +++ b/examples/opengl/hellogl_es2/hellogl_es2.pro @@ -25,9 +25,3 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl_es2 sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hellogl_es2.pro sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl_es2 INSTALLS += target sources - - -wince*: { - QMAKE_LIBS += "libGLESv2.lib" - -}
\ No newline at end of file diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp index 7291b97..bce69e4 100644 --- a/examples/script/customclass/bytearrayclass.cpp +++ b/examples/script/customclass/bytearrayclass.cpp @@ -72,18 +72,6 @@ private: int m_last; }; -static qint32 toArrayIndex(const QString &str) -{ - QByteArray bytes = str.toUtf8(); - char *eptr; - quint32 pos = strtoul(bytes.constData(), &eptr, 10); - if ((eptr == bytes.constData() + bytes.size()) - && (QByteArray::number(pos) == bytes)) { - return pos; - } - return -1; -} - //! [0] ByteArrayClass::ByteArrayClass(QScriptEngine *engine) : QObject(engine), QScriptClass(engine) @@ -120,8 +108,9 @@ QScriptClass::QueryFlags ByteArrayClass::queryProperty(const QScriptValue &objec if (name == length) { return flags; } else { - qint32 pos = toArrayIndex(name); - if (pos == -1) + bool isArrayIndex; + qint32 pos = name.toArrayIndex(&isArrayIndex); + if (!isArrayIndex) return 0; *id = pos; if ((flags & HandlesReadAccess) && (pos >= ba->size())) |