diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-10-25 23:26:53 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-10-25 23:26:53 (GMT) |
commit | cbb1b29d397c063fc3bcae04c5b062f20cbd12c5 (patch) | |
tree | d89cebe45c9f6dfdcab34a95da19ee0d670e30f5 /examples | |
parent | ed7d58f6668be4ffb5f915722dee81c864f74844 (diff) | |
parent | 9aa00de1d277763c0f7a380fde27face60e5f686 (diff) | |
download | Qt-cbb1b29d397c063fc3bcae04c5b062f20cbd12c5.zip Qt-cbb1b29d397c063fc3bcae04c5b062f20cbd12c5.tar.gz Qt-cbb1b29d397c063fc3bcae04c5b062f20cbd12c5.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Conflicts:
tools/qdoc3/cppcodemarker.cpp
Diffstat (limited to 'examples')
6 files changed, 150 insertions, 13 deletions
diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp index 95525c5..28de6da 100644 --- a/examples/gestures/imagegestures/imagewidget.cpp +++ b/examples/gestures/imagegestures/imagewidget.cpp @@ -128,9 +128,9 @@ void ImageWidget::panTriggered(QPanGesture *gesture) setCursor(Qt::ArrowCursor); } #endif - QSizeF lastOffset = gesture->offset(); - horizontalOffset += lastOffset.width(); - verticalOffset += lastOffset.height(); + QPointF lastOffset = gesture->offset(); + horizontalOffset += lastOffset.x(); + verticalOffset += lastOffset.y(); update(); } 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/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() |