diff options
Diffstat (limited to 'examples')
54 files changed, 557 insertions, 87 deletions
diff --git a/examples/activeqt/hierarchy/objects.cpp b/examples/activeqt/hierarchy/objects.cpp index 918f219..bb0b701 100644 --- a/examples/activeqt/hierarchy/objects.cpp +++ b/examples/activeqt/hierarchy/objects.cpp @@ -62,7 +62,7 @@ void QParentWidget::createSubWidget(const QString &name) //! [1] //! [2] QSubWidget *QParentWidget::subWidget(const QString &name) { - return qFindChild<QSubWidget*>(this, name); + return findChild<QSubWidget*>(name); } //! [2] diff --git a/examples/animation/easing/window.cpp b/examples/animation/easing/window.cpp index a555024..8d9775d 100644 --- a/examples/animation/easing/window.cpp +++ b/examples/animation/easing/window.cpp @@ -44,7 +44,7 @@ Window::Window(QWidget *parent) : QWidget(parent), m_iconSize(64, 64) { m_ui.setupUi(this); - QButtonGroup *buttonGroup = qFindChild<QButtonGroup *>(this); // ### workaround for uic in 4.4 + QButtonGroup *buttonGroup = findChild<QButtonGroup *>(); // ### workaround for uic in 4.4 m_ui.easingCurvePicker->setIconSize(m_iconSize); m_ui.easingCurvePicker->setMinimumHeight(m_iconSize.height() + 50); buttonGroup->setId(m_ui.lineRadio, 0); diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro index 7149986..f6e09a2 100644 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.pro +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.pro @@ -22,7 +22,7 @@ symbian:{ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) TARGET.EPOCALLOWDLLDATA = 1 - importFiles.sources = ImageProviderCore/qmlimageproviderplugin.dll ImageProviderCore/qmldir + importFiles.files = ImageProviderCore/qmlimageproviderplugin.dll ImageProviderCore/qmldir importFiles.path = ImageProviderCore DEPLOYMENT = importFiles } diff --git a/examples/declarative/cppextensions/qwidgets/qwidgets.pro b/examples/declarative/cppextensions/qwidgets/qwidgets.pro index 2e610f9..0f5398b 100644 --- a/examples/declarative/cppextensions/qwidgets/qwidgets.pro +++ b/examples/declarative/cppextensions/qwidgets/qwidgets.pro @@ -17,7 +17,7 @@ symbian:{ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) TARGET.EPOCALLOWDLLDATA = 1 - importFiles.sources = QWidgets/qmlqwidgetsplugin.dll QWidgets/qmldir + importFiles.files = QWidgets/qmlqwidgetsplugin.dll QWidgets/qmldir importFiles.path = QWidgets DEPLOYMENT = importFiles diff --git a/examples/designer/calculatorbuilder/calculatorform.cpp b/examples/designer/calculatorbuilder/calculatorform.cpp index 34c869e..fa6ccb3 100644 --- a/examples/designer/calculatorbuilder/calculatorform.cpp +++ b/examples/designer/calculatorbuilder/calculatorform.cpp @@ -58,9 +58,9 @@ CalculatorForm::CalculatorForm(QWidget *parent) //! [1] //! [2] - ui_inputSpinBox1 = qFindChild<QSpinBox*>(this, "inputSpinBox1"); - ui_inputSpinBox2 = qFindChild<QSpinBox*>(this, "inputSpinBox2"); - ui_outputWidget = qFindChild<QLabel*>(this, "outputWidget"); + ui_inputSpinBox1 = findChild<QSpinBox*>("inputSpinBox1"); + ui_inputSpinBox2 = findChild<QSpinBox*>("inputSpinBox2"); + ui_outputWidget = findChild<QLabel*>("outputWidget"); //! [2] //! [3] diff --git a/examples/desktop/systray/systray.pro b/examples/desktop/systray/systray.pro index 9b25916..710452b 100644 --- a/examples/desktop/systray/systray.pro +++ b/examples/desktop/systray/systray.pro @@ -14,10 +14,10 @@ symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) wince* { CONFIG(debug, release|debug) { - addPlugins.sources = $$QT_BUILD_TREE/plugins/imageformats/qsvgd4.dll + addPlugins.files = $$QT_BUILD_TREE/plugins/imageformats/qsvgd4.dll } CONFIG(release, release|debug) { - addPlugins.sources = $$QT_BUILD_TREE/plugins/imageformats/qsvg4.dll + addPlugins.files = $$QT_BUILD_TREE/plugins/imageformats/qsvg4.dll } addPlugins.path = imageformats DEPLOYMENT += addPlugins diff --git a/examples/draganddrop/puzzle/pieceslist.cpp b/examples/draganddrop/puzzle/pieceslist.cpp index 77e8723..6e82145 100644 --- a/examples/draganddrop/puzzle/pieceslist.cpp +++ b/examples/draganddrop/puzzle/pieceslist.cpp @@ -103,7 +103,7 @@ void PiecesList::startDrag(Qt::DropActions /*supportedActions*/) QByteArray itemData; QDataStream dataStream(&itemData, QIODevice::WriteOnly); - QPixmap pixmap = qVariantValue<QPixmap>(item->data(Qt::UserRole)); + QPixmap pixmap = qvariant_cast<QPixmap>(item->data(Qt::UserRole)); QPoint location = item->data(Qt::UserRole+1).toPoint(); dataStream << pixmap << location; diff --git a/examples/draganddrop/puzzle/puzzle.pro b/examples/draganddrop/puzzle/puzzle.pro index 31786c7..c0400d8 100644 --- a/examples/draganddrop/puzzle/puzzle.pro +++ b/examples/draganddrop/puzzle/puzzle.pro @@ -7,6 +7,8 @@ SOURCES = main.cpp \ pieceslist.cpp \ puzzlewidget.cpp +QMAKE_PROJECT_NAME = dndpuzzle + # install target.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/puzzle sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.jpg @@ -16,12 +18,12 @@ INSTALLS += target sources symbian:{ TARGET.UID3 = 0xA000CF65 include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - addFile.sources = example.jpg + addFile.files = example.jpg addFile.path = . DEPLOYMENT += addFile } wince*: { - addFile.sources = example.jpg + addFile.files = example.jpg addFile.path = . DEPLOYMENT += addFile } diff --git a/examples/graphicsview/diagramscene/mainwindow.cpp b/examples/graphicsview/diagramscene/mainwindow.cpp index 7d82df0..03e821d 100644 --- a/examples/graphicsview/diagramscene/mainwindow.cpp +++ b/examples/graphicsview/diagramscene/mainwindow.cpp @@ -236,7 +236,7 @@ void MainWindow::textColorChanged() textAction = qobject_cast<QAction *>(sender()); fontColorToolButton->setIcon(createColorToolButtonIcon( ":/images/textpointer.png", - qVariantValue<QColor>(textAction->data()))); + qvariant_cast<QColor>(textAction->data()))); textButtonTriggered(); } //! [12] @@ -247,7 +247,7 @@ void MainWindow::itemColorChanged() fillAction = qobject_cast<QAction *>(sender()); fillColorToolButton->setIcon(createColorToolButtonIcon( ":/images/floodfill.png", - qVariantValue<QColor>(fillAction->data()))); + qvariant_cast<QColor>(fillAction->data()))); fillButtonTriggered(); } //! [13] @@ -258,7 +258,7 @@ void MainWindow::lineColorChanged() lineAction = qobject_cast<QAction *>(sender()); lineColorToolButton->setIcon(createColorToolButtonIcon( ":/images/linecolor.png", - qVariantValue<QColor>(lineAction->data()))); + qvariant_cast<QColor>(lineAction->data()))); lineButtonTriggered(); } //! [14] @@ -266,21 +266,21 @@ void MainWindow::lineColorChanged() //! [15] void MainWindow::textButtonTriggered() { - scene->setTextColor(qVariantValue<QColor>(textAction->data())); + scene->setTextColor(qvariant_cast<QColor>(textAction->data())); } //! [15] //! [16] void MainWindow::fillButtonTriggered() { - scene->setItemColor(qVariantValue<QColor>(fillAction->data())); + scene->setItemColor(qvariant_cast<QColor>(fillAction->data())); } //! [16] //! [17] void MainWindow::lineButtonTriggered() { - scene->setLineColor(qVariantValue<QColor>(lineAction->data())); + scene->setLineColor(qvariant_cast<QColor>(lineAction->data())); } //! [17] diff --git a/examples/graphicsview/dragdroprobot/robot.cpp b/examples/graphicsview/dragdroprobot/robot.cpp index 44ecda3..caca309 100644 --- a/examples/graphicsview/dragdroprobot/robot.cpp +++ b/examples/graphicsview/dragdroprobot/robot.cpp @@ -77,7 +77,7 @@ void RobotPart::dropEvent(QGraphicsSceneDragDropEvent *event) { dragOver = false; if (event->mimeData()->hasColor()) - color = qVariantValue<QColor>(event->mimeData()->colorData()); + color = qvariant_cast<QColor>(event->mimeData()->colorData()); update(); } //! [3] @@ -139,7 +139,7 @@ void RobotHead::dropEvent(QGraphicsSceneDragDropEvent *event) { if (event->mimeData()->hasImage()) { dragOver = false; - pixmap = qVariantValue<QPixmap>(event->mimeData()->imageData()); + pixmap = qvariant_cast<QPixmap>(event->mimeData()->imageData()); update(); } else { RobotPart::dropEvent(event); diff --git a/examples/graphicsview/flowlayout/flowlayout.pro b/examples/graphicsview/flowlayout/flowlayout.pro index c029d6c..ce35367 100644 --- a/examples/graphicsview/flowlayout/flowlayout.pro +++ b/examples/graphicsview/flowlayout/flowlayout.pro @@ -1,12 +1,10 @@ -###################################################################### -# Automatically generated by qmake (2.01a) ma 30. mar 12:46:15 2009 -###################################################################### - TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += . +QMAKE_PROJECT_NAME = flowlayout_graphicsview + # Input HEADERS += flowlayout.h window.h SOURCES += flowlayout.cpp main.cpp window.cpp diff --git a/examples/graphicsview/padnavigator/padnavigator.cpp b/examples/graphicsview/padnavigator/padnavigator.cpp index 4988664..3ea68de 100644 --- a/examples/graphicsview/padnavigator/padnavigator.cpp +++ b/examples/graphicsview/padnavigator/padnavigator.cpp @@ -135,9 +135,9 @@ PadNavigator::PadNavigator(const QSize &size, QWidget *parent) smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad); smoothFlipXRotation->setEasingCurve(QEasingCurve::InOutQuad); smoothFlipYRotation->setEasingCurve(QEasingCurve::InOutQuad); - smoothFlipScale->setKeyValueAt(0, qVariantValue<qreal>(1.0)); - smoothFlipScale->setKeyValueAt(0.5, qVariantValue<qreal>(0.7)); - smoothFlipScale->setKeyValueAt(1, qVariantValue<qreal>(1.0)); + smoothFlipScale->setKeyValueAt(0, qvariant_cast<qreal>(1.0)); + smoothFlipScale->setKeyValueAt(0.5, qvariant_cast<qreal>(0.7)); + smoothFlipScale->setKeyValueAt(1, qvariant_cast<qreal>(1.0)); flipAnimation->addAnimation(smoothFlipRotation); flipAnimation->addAnimation(smoothFlipScale); flipAnimation->addAnimation(smoothFlipXRotation); @@ -172,13 +172,13 @@ PadNavigator::PadNavigator(const QSize &size, QWidget *parent) frontState->assignProperty(pad, "fill", false); frontState->assignProperty(splash, "opacity", 0.0); frontState->assignProperty(backItem, "visible", false); - frontState->assignProperty(flipRotation, "angle", qVariantValue<qreal>(0.0)); + frontState->assignProperty(flipRotation, "angle", qvariant_cast<qreal>(0.0)); frontState->assignProperty(selectionItem, "visible", true); backState->assignProperty(pad, "fill", true); backState->assignProperty(backItem, "visible", true); - backState->assignProperty(xRotation, "angle", qVariantValue<qreal>(0.0)); - backState->assignProperty(yRotation, "angle", qVariantValue<qreal>(0.0)); - backState->assignProperty(flipRotation, "angle", qVariantValue<qreal>(180.0)); + backState->assignProperty(xRotation, "angle", qvariant_cast<qreal>(0.0)); + backState->assignProperty(yRotation, "angle", qvariant_cast<qreal>(0.0)); + backState->assignProperty(flipRotation, "angle", qvariant_cast<qreal>(180.0)); backState->assignProperty(selectionItem, "visible", false); stateMachine->addDefaultAnimation(smoothXRotation); stateMachine->addDefaultAnimation(smoothYRotation); diff --git a/examples/itemviews/coloreditorfactory/colorlisteditor.cpp b/examples/itemviews/coloreditorfactory/colorlisteditor.cpp index 1af5831..4f4a954 100644 --- a/examples/itemviews/coloreditorfactory/colorlisteditor.cpp +++ b/examples/itemviews/coloreditorfactory/colorlisteditor.cpp @@ -50,7 +50,7 @@ ColorListEditor::ColorListEditor(QWidget *widget) : QComboBox(widget) //! [0] QColor ColorListEditor::color() const { - return qVariantValue<QColor>(itemData(currentIndex(), Qt::DecorationRole)); + return qvariant_cast<QColor>(itemData(currentIndex(), Qt::DecorationRole)); } //! [0] diff --git a/examples/itemviews/puzzle/piecesmodel.cpp b/examples/itemviews/puzzle/piecesmodel.cpp index e110cf1..e55663b 100644 --- a/examples/itemviews/puzzle/piecesmodel.cpp +++ b/examples/itemviews/puzzle/piecesmodel.cpp @@ -124,7 +124,7 @@ QMimeData *PiecesModel::mimeData(const QModelIndexList &indexes) const foreach (QModelIndex index, indexes) { if (index.isValid()) { - QPixmap pixmap = qVariantValue<QPixmap>(data(index, Qt::UserRole)); + QPixmap pixmap = qvariant_cast<QPixmap>(data(index, Qt::UserRole)); QPoint location = data(index, Qt::UserRole+1).toPoint(); stream << pixmap << location; } diff --git a/examples/itemviews/stardelegate/main.cpp b/examples/itemviews/stardelegate/main.cpp index d9f655d..444017e 100644 --- a/examples/itemviews/stardelegate/main.cpp +++ b/examples/itemviews/stardelegate/main.cpp @@ -71,7 +71,7 @@ void populateTableWidget(QTableWidget *tableWidget) QTableWidgetItem *item2 = new QTableWidgetItem(staticData[row].artist); QTableWidgetItem *item3 = new QTableWidgetItem; item3->setData(0, - qVariantFromValue(StarRating(staticData[row].rating))); + QVariant::fromValue(StarRating(staticData[row].rating))); tableWidget->setItem(row, 0, item0); tableWidget->setItem(row, 1, item1); diff --git a/examples/itemviews/stardelegate/stardelegate.cpp b/examples/itemviews/stardelegate/stardelegate.cpp index 44dd54f..ebb2e38 100644 --- a/examples/itemviews/stardelegate/stardelegate.cpp +++ b/examples/itemviews/stardelegate/stardelegate.cpp @@ -48,8 +48,8 @@ void StarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - if (qVariantCanConvert<StarRating>(index.data())) { - StarRating starRating = qVariantValue<StarRating>(index.data()); + if (index.data().canConvert<StarRating>()) { + StarRating starRating = qvariant_cast<StarRating>(index.data()); if (option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); @@ -66,8 +66,8 @@ void StarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, QSize StarDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - if (qVariantCanConvert<StarRating>(index.data())) { - StarRating starRating = qVariantValue<StarRating>(index.data()); + if (index.data().canConvert<StarRating>()) { + StarRating starRating = qvariant_cast<StarRating>(index.data()); return starRating.sizeHint(); } else { return QStyledItemDelegate::sizeHint(option, index); @@ -81,7 +81,7 @@ QWidget *StarDelegate::createEditor(QWidget *parent, const QModelIndex &index) const { - if (qVariantCanConvert<StarRating>(index.data())) { + if (index.data().canConvert<StarRating>()) { StarEditor *editor = new StarEditor(parent); connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor())); @@ -96,8 +96,8 @@ QWidget *StarDelegate::createEditor(QWidget *parent, void StarDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { - if (qVariantCanConvert<StarRating>(index.data())) { - StarRating starRating = qVariantValue<StarRating>(index.data()); + if (index.data().canConvert<StarRating>()) { + StarRating starRating = qvariant_cast<StarRating>(index.data()); StarEditor *starEditor = qobject_cast<StarEditor *>(editor); starEditor->setStarRating(starRating); } else { @@ -110,9 +110,9 @@ void StarDelegate::setEditorData(QWidget *editor, void StarDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { - if (qVariantCanConvert<StarRating>(index.data())) { + if (index.data().canConvert<StarRating>()) { StarEditor *starEditor = qobject_cast<StarEditor *>(editor); - model->setData(index, qVariantFromValue(starEditor->starRating())); + model->setData(index, QVariant::fromValue(starEditor->starRating())); } else { QStyledItemDelegate::setModelData(editor, model, index); } diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index 5ab4918..6eb0763 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -155,7 +155,7 @@ void AudioTest::modeChanged(int idx) deviceBox->clear(); foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(mode)) - deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); + deviceBox->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); deviceBox->setCurrentIndex(0); deviceChanged(0); diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 4e5f2a3..cf18335 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -237,7 +237,7 @@ void InputTest::initializeWindow() m_deviceBox = new QComboBox(this); QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); for(int i = 0; i < devices.size(); ++i) - m_deviceBox->addItem(devices.at(i).deviceName(), qVariantFromValue(devices.at(i))); + m_deviceBox->addItem(devices.at(i).deviceName(), QVariant::fromValue(devices.at(i))); connect(m_deviceBox, SIGNAL(activated(int)), SLOT(deviceChanged(int))); layout->addWidget(m_deviceBox); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index 451cc67..93020bc 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -176,7 +176,7 @@ void AudioTest::initializeWindow() m_deviceBox = new QComboBox(this); foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) - m_deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); + m_deviceBox->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); connect(m_deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); layout->addWidget(m_deviceBox); diff --git a/examples/network/multicastreceiver/main.cpp b/examples/network/multicastreceiver/main.cpp new file mode 100644 index 0000000..8483271 --- /dev/null +++ b/examples/network/multicastreceiver/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> + +#include "receiver.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Receiver receiver; + receiver.show(); + return receiver.exec(); +} diff --git a/examples/network/multicastreceiver/multicastreceiver.pro b/examples/network/multicastreceiver/multicastreceiver.pro new file mode 100644 index 0000000..400c92e --- /dev/null +++ b/examples/network/multicastreceiver/multicastreceiver.pro @@ -0,0 +1,12 @@ +HEADERS = receiver.h +SOURCES = receiver.cpp \ + main.cpp +QT += network + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/network/multicastreceiver +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS multicastreceiver.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/network/multicastreceiver +INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/multicastreceiver/receiver.cpp b/examples/network/multicastreceiver/receiver.cpp new file mode 100644 index 0000000..073fdce --- /dev/null +++ b/examples/network/multicastreceiver/receiver.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include <QtNetwork> + +#include "receiver.h" + +Receiver::Receiver(QWidget *parent) + : QDialog(parent) +{ + groupAddress = QHostAddress("239.255.43.21"); + + statusLabel = new QLabel(tr("Listening for multicasted messages")); + quitButton = new QPushButton(tr("&Quit")); + + udpSocket = new QUdpSocket(this); + udpSocket->bind(45454, QUdpSocket::ShareAddress); + udpSocket->joinMulticastGroup(groupAddress); + + connect(udpSocket, SIGNAL(readyRead()), + this, SLOT(processPendingDatagrams())); + connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); + + QHBoxLayout *buttonLayout = new QHBoxLayout; + buttonLayout->addStretch(1); + buttonLayout->addWidget(quitButton); + buttonLayout->addStretch(1); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(statusLabel); + mainLayout->addLayout(buttonLayout); + setLayout(mainLayout); + + setWindowTitle(tr("Multicast Receiver")); +} + +void Receiver::processPendingDatagrams() +{ + while (udpSocket->hasPendingDatagrams()) { + QByteArray datagram; + datagram.resize(udpSocket->pendingDatagramSize()); + udpSocket->readDatagram(datagram.data(), datagram.size()); + statusLabel->setText(tr("Received datagram: \"%1\"") + .arg(datagram.data())); + } +} diff --git a/examples/network/multicastreceiver/receiver.h b/examples/network/multicastreceiver/receiver.h new file mode 100644 index 0000000..e226028 --- /dev/null +++ b/examples/network/multicastreceiver/receiver.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef RECEIVER_H +#define RECEIVER_H + +#include <QDialog> +#include <QHostAddress> + +QT_BEGIN_NAMESPACE +class QLabel; +class QPushButton; +class QUdpSocket; +QT_END_NAMESPACE + +class Receiver : public QDialog +{ + Q_OBJECT + +public: + Receiver(QWidget *parent = 0); + +private slots: + void processPendingDatagrams(); + +private: + QLabel *statusLabel; + QPushButton *quitButton; + QUdpSocket *udpSocket; + QHostAddress groupAddress; +}; + +#endif diff --git a/examples/network/multicastsender/main.cpp b/examples/network/multicastsender/main.cpp new file mode 100644 index 0000000..9309322 --- /dev/null +++ b/examples/network/multicastsender/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> + +#include "sender.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Sender sender; + sender.show(); + return sender.exec(); +} diff --git a/examples/network/multicastsender/multicastsender.pro b/examples/network/multicastsender/multicastsender.pro new file mode 100644 index 0000000..7543f00 --- /dev/null +++ b/examples/network/multicastsender/multicastsender.pro @@ -0,0 +1,12 @@ +HEADERS = sender.h +SOURCES = sender.cpp \ + main.cpp +QT += network + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/network/multicastsender +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS multicastsender.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/network/multicastsender +INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/multicastsender/sender.cpp b/examples/network/multicastsender/sender.cpp new file mode 100644 index 0000000..7fa9750 --- /dev/null +++ b/examples/network/multicastsender/sender.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include <QtNetwork> + +#include "sender.h" + +Sender::Sender(QWidget *parent) + : QDialog(parent) +{ + groupAddress = QHostAddress("239.255.43.21"); + + statusLabel = new QLabel(tr("Ready to multicast datagrams to group %1 on port 45454").arg(groupAddress.toString())); + + ttlLabel = new QLabel(tr("TTL for multicast datagrams:")); + ttlSpinBox = new QSpinBox; + ttlSpinBox->setRange(0, 255); + + QHBoxLayout *ttlLayout = new QHBoxLayout; + ttlLayout->addWidget(ttlLabel); + ttlLayout->addWidget(ttlSpinBox); + + startButton = new QPushButton(tr("&Start")); + quitButton = new QPushButton(tr("&Quit")); + + buttonBox = new QDialogButtonBox; + buttonBox->addButton(startButton, QDialogButtonBox::ActionRole); + buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); + + timer = new QTimer(this); + udpSocket = new QUdpSocket(this); + messageNo = 1; + + connect(ttlSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ttlChanged(int))); + connect(startButton, SIGNAL(clicked()), this, SLOT(startSending())); + connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); + connect(timer, SIGNAL(timeout()), this, SLOT(sendDatagram())); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(statusLabel); + mainLayout->addLayout(ttlLayout); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); + + setWindowTitle(tr("Multicast Sender")); + ttlSpinBox->setValue(1); +} + +void Sender::ttlChanged(int newTtl) +{ + udpSocket->setSocketOption(QAbstractSocket::MulticastTtlOption, newTtl); +} + +void Sender::startSending() +{ + startButton->setEnabled(false); + timer->start(1000); +} + +void Sender::sendDatagram() +{ + statusLabel->setText(tr("Now sending datagram %1").arg(messageNo)); + QByteArray datagram = "Multicast message " + QByteArray::number(messageNo); + udpSocket->writeDatagram(datagram.data(), datagram.size(), + groupAddress, 45454); + ++messageNo; +} diff --git a/examples/network/multicastsender/sender.h b/examples/network/multicastsender/sender.h new file mode 100644 index 0000000..f119883 --- /dev/null +++ b/examples/network/multicastsender/sender.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SENDER_H +#define SENDER_H + +#include <QDialog> +#include <QHostAddress> + +QT_BEGIN_NAMESPACE +class QDialogButtonBox; +class QLabel; +class QPushButton; +class QTimer; +class QUdpSocket; +class QSpinBox; +QT_END_NAMESPACE + +class Sender : public QDialog +{ + Q_OBJECT + +public: + Sender(QWidget *parent = 0); + +private slots: + void ttlChanged(int newTtl); + void startSending(); + void sendDatagram(); + +private: + QLabel *statusLabel; + QLabel *ttlLabel; + QSpinBox *ttlSpinBox; + QPushButton *startButton; + QPushButton *quitButton; + QDialogButtonBox *buttonBox; + QUdpSocket *udpSocket; + QTimer *timer; + QHostAddress groupAddress; + int messageNo; +}; + +#endif diff --git a/examples/network/network.pro b/examples/network/network.pro index 458561a..0012a97 100644 --- a/examples/network/network.pro +++ b/examples/network/network.pro @@ -16,7 +16,9 @@ SUBDIRS = \ threadedfortuneserver \ googlesuggest \ torrent \ - bearermonitor + bearermonitor \ + multicastreceiver \ + multicastsender contains(QT_CONFIG, svg) { SUBDIRS += bearercloud diff --git a/examples/network/torrent/bencodeparser.cpp b/examples/network/torrent/bencodeparser.cpp index d6b6078..aa498d6 100644 --- a/examples/network/torrent/bencodeparser.cpp +++ b/examples/network/torrent/bencodeparser.cpp @@ -171,7 +171,7 @@ bool BencodeParser::getList(QList<QVariant> *list) else if (getList(&tmpList)) tmp << tmpList; else if (getDictionary(&dictionary)) - tmp << qVariantFromValue<QMap<QByteArray, QVariant> >(dictionary); + tmp << QVariant::fromValue<QMap<QByteArray, QVariant> >(dictionary); else { errString = QString("error at index %1").arg(index); return false; @@ -217,7 +217,7 @@ bool BencodeParser::getDictionary(QMap<QByteArray, QVariant> *dictionary) else if (getList(&tmpList)) tmp.insert(key, tmpList); else if (getDictionary(&dictionary)) - tmp.insert(key, qVariantFromValue<QMap<QByteArray, QVariant> >(dictionary)); + tmp.insert(key, QVariant::fromValue<QMap<QByteArray, QVariant> >(dictionary)); else { errString = QString("error at index %1").arg(index); return false; diff --git a/examples/network/torrent/metainfo.cpp b/examples/network/torrent/metainfo.cpp index a6e7511..a7cd978 100644 --- a/examples/network/torrent/metainfo.cpp +++ b/examples/network/torrent/metainfo.cpp @@ -83,7 +83,7 @@ bool MetaInfo::parse(const QByteArray &data) if (!dict.contains("info")) return false; - QMap<QByteArray, QVariant> info = qVariantValue<Dictionary>(dict.value("info")); + QMap<QByteArray, QVariant> info = qvariant_cast<Dictionary>(dict.value("info")); if (info.contains("files")) { metaInfoFileForm = MultiFileForm; @@ -91,7 +91,7 @@ bool MetaInfo::parse(const QByteArray &data) QList<QVariant> files = info.value("files").toList(); for (int i = 0; i < files.size(); ++i) { - QMap<QByteArray, QVariant> file = qVariantValue<Dictionary>(files.at(i)); + QMap<QByteArray, QVariant> file = qvariant_cast<Dictionary>(files.at(i)); QList<QVariant> pathElements = file.value("path").toList(); QByteArray path; foreach (QVariant p, pathElements) { diff --git a/examples/network/torrent/trackerclient.cpp b/examples/network/torrent/trackerclient.cpp index 61d7e95..07194fa 100644 --- a/examples/network/torrent/trackerclient.cpp +++ b/examples/network/torrent/trackerclient.cpp @@ -210,7 +210,7 @@ void TrackerClient::httpRequestDone(bool error) QList<QVariant> peerTmp = peerEntry.toList(); for (int i = 0; i < peerTmp.size(); ++i) { TorrentPeer tmp; - QMap<QByteArray, QVariant> peer = qVariantValue<QMap<QByteArray, QVariant> >(peerTmp.at(i)); + QMap<QByteArray, QVariant> peer = qvariant_cast<QMap<QByteArray, QVariant> >(peerTmp.at(i)); tmp.id = QString::fromUtf8(peer.value("peer id").toByteArray()); tmp.address.setAddress(QString::fromUtf8(peer.value("ip").toByteArray())); tmp.port = peer.value("port").toInt(); diff --git a/examples/painting/svgviewer/svgviewer.pro b/examples/painting/svgviewer/svgviewer.pro index 4809b91..6417849 100644 --- a/examples/painting/svgviewer/svgviewer.pro +++ b/examples/painting/svgviewer/svgviewer.pro @@ -17,7 +17,7 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/painting/svgviewer INSTALLS += target sources wince*: { - addFiles.sources = files\\*.svg + addFiles.files = files\\*.svg addFiles.path = "\\My Documents" DEPLOYMENT += addFiles } @@ -25,7 +25,7 @@ wince*: { symbian: { TARGET.UID3 = 0xA000A64E include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - addFiles.sources = files\\*.svg + addFiles.files = files\\*.svg addFiles.path = . DEPLOYMENT += addFiles } diff --git a/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro b/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro index 0574b2d..67aa1ff 100644 --- a/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro +++ b/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro @@ -13,7 +13,7 @@ INSTALLS += target sources symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) wince*: { - addFiles.sources = main.cpp mainwindow.cpp + addFiles.files = main.cpp mainwindow.cpp addFiles.path = . DEPLOYMENT += addFiles } diff --git a/examples/richtext/textobject/svgtextobject.cpp b/examples/richtext/textobject/svgtextobject.cpp index c84725d..2442623 100644 --- a/examples/richtext/textobject/svgtextobject.cpp +++ b/examples/richtext/textobject/svgtextobject.cpp @@ -48,7 +48,7 @@ QSizeF SvgTextObject::intrinsicSize(QTextDocument * /*doc*/, int /*posInDocument*/, const QTextFormat &format) { - QImage bufferedImage = qVariantValue<QImage>(format.property(Window::SvgData)); + QImage bufferedImage = qvariant_cast<QImage>(format.property(Window::SvgData)); QSize size = bufferedImage.size(); if (size.height() > 25) @@ -63,7 +63,7 @@ void SvgTextObject::drawObject(QPainter *painter, const QRectF &rect, QTextDocument * /*doc*/, int /*posInDocument*/, const QTextFormat &format) { - QImage bufferedImage = qVariantValue<QImage>(format.property(Window::SvgData)); + QImage bufferedImage = qvariant_cast<QImage>(format.property(Window::SvgData)); painter->drawImage(rect, bufferedImage); } diff --git a/examples/richtext/textobject/textobject.pro b/examples/richtext/textobject/textobject.pro index 4fa9cb0..222b0fe 100644 --- a/examples/richtext/textobject/textobject.pro +++ b/examples/richtext/textobject/textobject.pro @@ -12,7 +12,7 @@ sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/richtext/textobject INSTALLS += target sources -filesToDeploy.sources = files/*.svg +filesToDeploy.files = files/*.svg filesToDeploy.path = files DEPLOYMENT += filesToDeploy diff --git a/examples/script/calculator/calculator.pro b/examples/script/calculator/calculator.pro index 6385d7e..f328fc3 100644 --- a/examples/script/calculator/calculator.pro +++ b/examples/script/calculator/calculator.pro @@ -2,6 +2,7 @@ QT += script CONFIG += uitools RESOURCES += calculator.qrc SOURCES += main.cpp +QMAKE_PROJECT_NAME = scripted_calculator contains(QT_CONFIG, scripttools): QT += scripttools diff --git a/examples/script/calculator/main.cpp b/examples/script/calculator/main.cpp index 8030a87..c258a9b 100644 --- a/examples/script/calculator/main.cpp +++ b/examples/script/calculator/main.cpp @@ -89,7 +89,7 @@ int main(int argc, char **argv) //! [2] #if !defined(QT_NO_SCRIPTTOOLS) - QLineEdit *display = qFindChild<QLineEdit*>(ui, "display"); + QLineEdit *display = ui->findChild<QLineEdit*>("display"); QObject::connect(display, SIGNAL(returnPressed()), debugWindow, SLOT(show())); #endif diff --git a/examples/script/context2d/context2d.cpp b/examples/script/context2d/context2d.cpp index c408736..49fc3bc 100644 --- a/examples/script/context2d/context2d.cpp +++ b/examples/script/context2d/context2d.cpp @@ -278,7 +278,7 @@ QVariant Context2D::strokeStyle() const void Context2D::setStrokeStyle(const QVariant &style) { - if (qVariantCanConvert<CanvasGradient>(style)) { + if (style.canConvert<CanvasGradient>()) { CanvasGradient cg = qvariant_cast<CanvasGradient>(style); m_state.strokeStyle = cg.value; } else { @@ -296,7 +296,7 @@ QVariant Context2D::fillStyle() const //! [3] void Context2D::setFillStyle(const QVariant &style) { - if (qVariantCanConvert<CanvasGradient>(style)) { + if (style.canConvert<CanvasGradient>()) { CanvasGradient cg = qvariant_cast<CanvasGradient>(style); m_state.fillStyle = cg.value; } else { diff --git a/examples/script/context2d/context2d.pro b/examples/script/context2d/context2d.pro index 54f5c31..6a0e397 100644 --- a/examples/script/context2d/context2d.pro +++ b/examples/script/context2d/context2d.pro @@ -27,6 +27,6 @@ symbian:{ include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) TARGET.EPOCHEAPSIZE = 0x200000 0xA00000 contextScripts.path = . - contextScripts.sources = scripts + contextScripts.files = scripts DEPLOYMENT += contextScripts } diff --git a/examples/script/context2d/domimage.cpp b/examples/script/context2d/domimage.cpp index 801e1a2..f655c6f 100644 --- a/examples/script/context2d/domimage.cpp +++ b/examples/script/context2d/domimage.cpp @@ -84,7 +84,7 @@ static QScriptValue Image(QScriptContext *context, QScriptEngine *env) { QScriptValue val = context->thisObject(); DomImage *image = new DomImage(); - QScriptValue klass = env->newVariant(qVariantFromValue(image)); + QScriptValue klass = env->newVariant(QVariant::fromValue(image)); klass.setPrototype(DomImage::s_self); return klass; } diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp index 5ecee0a..7bf6d3f 100644 --- a/examples/script/customclass/bytearrayclass.cpp +++ b/examples/script/customclass/bytearrayclass.cpp @@ -88,7 +88,7 @@ ByteArrayClass::ByteArrayClass(QScriptEngine *engine) proto.setPrototype(global.property("Object").property("prototype")); ctor = engine->newFunction(construct, proto); - ctor.setData(qScriptValueFromValue(engine, this)); + ctor.setData(engine->toScriptValue(this)); } //! [0] @@ -204,7 +204,7 @@ QScriptValue ByteArrayClass::newInstance(int size) //! [1] QScriptValue ByteArrayClass::newInstance(const QByteArray &ba) { - QScriptValue data = engine()->newVariant(qVariantFromValue(ba)); + QScriptValue data = engine()->newVariant(QVariant::fromValue(ba)); return engine()->newObject(this, data); } //! [1] @@ -228,7 +228,7 @@ QScriptValue ByteArrayClass::toScriptValue(QScriptEngine *eng, const QByteArray QScriptValue ctor = eng->globalObject().property("ByteArray"); ByteArrayClass *cls = qscriptvalue_cast<ByteArrayClass*>(ctor.data()); if (!cls) - return eng->newVariant(qVariantFromValue(ba)); + return eng->newVariant(QVariant::fromValue(ba)); return cls->newInstance(ba); } diff --git a/examples/script/marshal/main.cpp b/examples/script/marshal/main.cpp index adfeaf1..270cb56 100644 --- a/examples/script/marshal/main.cpp +++ b/examples/script/marshal/main.cpp @@ -49,7 +49,7 @@ QScriptValue toScriptValue(QScriptEngine *eng, const Container &cont) typename Container::const_iterator end = cont.end(); typename Container::const_iterator it; for (it = begin; it != end; ++it) - a.setProperty(quint32(it - begin), qScriptValueFromValue(eng, *it)); + a.setProperty(quint32(it - begin), eng->toScriptValue(*it)); return a; } diff --git a/examples/script/qstetrix/main.cpp b/examples/script/qstetrix/main.cpp index e12e26d..c802584 100644 --- a/examples/script/qstetrix/main.cpp +++ b/examples/script/qstetrix/main.cpp @@ -120,7 +120,7 @@ int main(int argc, char *argv[]) QScriptValue tetrix = ctor.construct(QScriptValueList() << scriptUi); //! [3] - QPushButton *debugButton = qFindChild<QPushButton*>(ui, "debugButton"); + QPushButton *debugButton = ui->findChild<QPushButton*>("debugButton"); #if !defined(QT_NO_SCRIPTTOOLS) QObject::connect(debugButton, SIGNAL(clicked()), debugger.action(QScriptEngineDebugger::InterruptAction), diff --git a/examples/sql/querymodel/customsqlmodel.cpp b/examples/sql/querymodel/customsqlmodel.cpp index f444acf..75d16b4 100644 --- a/examples/sql/querymodel/customsqlmodel.cpp +++ b/examples/sql/querymodel/customsqlmodel.cpp @@ -58,7 +58,7 @@ QVariant CustomSqlModel::data(const QModelIndex &index, int role) const return value.toString().toUpper(); } if (role == Qt::TextColorRole && index.column() == 1) - return qVariantFromValue(QColor(Qt::blue)); + return QVariant::fromValue(QColor(Qt::blue)); return value; } //! [0] diff --git a/examples/tools/customtype/main.cpp b/examples/tools/customtype/main.cpp index 229cd18..430613a 100644 --- a/examples/tools/customtype/main.cpp +++ b/examples/tools/customtype/main.cpp @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) //! [retrieving a custom value] Message retrieved = stored.value<Message>(); qDebug() << "Retrieved:" << retrieved; - retrieved = qVariantValue<Message>(stored); + retrieved = qvariant_cast<Message>(stored); qDebug() << "Retrieved:" << retrieved; //! [retrieving a custom value] diff --git a/examples/tools/echoplugin/echowindow/echowindow.pro b/examples/tools/echoplugin/echowindow/echowindow.pro index bdf8c41..c2abc6a 100644 --- a/examples/tools/echoplugin/echowindow/echowindow.pro +++ b/examples/tools/echoplugin/echowindow/echowindow.pro @@ -4,6 +4,7 @@ SOURCES = echowindow.cpp \ main.cpp TARGET = echoplugin +QMAKE_PROJECT_NAME = echopluginwindow win32 { debug:DESTDIR = ../debug/ release:DESTDIR = ../release/ diff --git a/examples/uitools/textfinder/textfinder.cpp b/examples/uitools/textfinder/textfinder.cpp index 4bb6600..1682acd 100644 --- a/examples/uitools/textfinder/textfinder.cpp +++ b/examples/uitools/textfinder/textfinder.cpp @@ -49,9 +49,9 @@ TextFinder::TextFinder(QWidget *parent) QWidget *formWidget = loadUiFile(); //! [1] - ui_findButton = qFindChild<QPushButton*>(this, "findButton"); - ui_textEdit = qFindChild<QTextEdit*>(this, "textEdit"); - ui_lineEdit = qFindChild<QLineEdit*>(this, "lineEdit"); + ui_findButton = findChild<QPushButton*>("findButton"); + ui_textEdit = findChild<QTextEdit*>("textEdit"); + ui_lineEdit = findChild<QLineEdit*>("lineEdit"); //! [0] //! [1] //! [2] diff --git a/examples/widgets/icons/icons.pro b/examples/widgets/icons/icons.pro index 39c7ab2..48b2da9 100644 --- a/examples/widgets/icons/icons.pro +++ b/examples/widgets/icons/icons.pro @@ -17,7 +17,7 @@ INSTALLS += target sources symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) wince*: { - imageFiles.sources = images/* + imageFiles.files = images/* wincewm*: { imageFiles.path = "/My Documents/My Pictures" } else { diff --git a/examples/widgets/movie/movie.pro b/examples/widgets/movie/movie.pro index 517fec7..d59bf2e 100644 --- a/examples/widgets/movie/movie.pro +++ b/examples/widgets/movie/movie.pro @@ -11,7 +11,7 @@ INSTALLS += target sources symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) wince*: { - addFiles.sources += *.mng + addFiles.files += *.mng addFiles.path = . DEPLOYMENT += addFiles DEPLOYMENT_PLUGIN += qmng diff --git a/examples/widgets/validators/localeselector.cpp b/examples/widgets/validators/localeselector.cpp index e4aae1a..0a48d66 100644 --- a/examples/widgets/validators/localeselector.cpp +++ b/examples/widgets/validators/localeselector.cpp @@ -294,7 +294,7 @@ LocaleSelector::LocaleSelector(QWidget *parent) QString text = QLocale::languageToString(QLocale::Language(l.lang)) + QLatin1Char('/') + QLocale::countryToString(QLocale::Country(l.country)); - addItem(text, qVariantFromValue(l)); + addItem(text, QVariant::fromValue(l)); } setCurrentIndex(curIndex); @@ -307,6 +307,6 @@ void LocaleSelector::emitLocaleSelected(int index) QVariant v = itemData(index); if (!v.isValid()) return; - SupportedLocale l = qVariantValue<SupportedLocale>(v); + SupportedLocale l = qvariant_cast<SupportedLocale>(v); emit localeSelected(QLocale(QLocale::Language(l.lang), QLocale::Country(l.country))); } diff --git a/examples/xml/dombookmarks/dombookmarks.pro b/examples/xml/dombookmarks/dombookmarks.pro index f906d2f..80bbec4 100644 --- a/examples/xml/dombookmarks/dombookmarks.pro +++ b/examples/xml/dombookmarks/dombookmarks.pro @@ -14,7 +14,7 @@ INSTALLS += target sources symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) wince*: { - addFiles.sources = frank.xbel jennifer.xbel + addFiles.files = frank.xbel jennifer.xbel addFiles.path = "\\My Documents" DEPLOYMENT += addFiles } diff --git a/examples/xml/htmlinfo/htmlinfo.pro b/examples/xml/htmlinfo/htmlinfo.pro index 5e9c8ca..94b3a07 100644 --- a/examples/xml/htmlinfo/htmlinfo.pro +++ b/examples/xml/htmlinfo/htmlinfo.pro @@ -2,7 +2,7 @@ SOURCES += main.cpp QT -= gui wince*|symbian:{ - htmlfiles.sources = *.html + htmlfiles.files = *.html htmlfiles.path = . DEPLOYMENT += htmlfiles } diff --git a/examples/xml/saxbookmarks/saxbookmarks.pro b/examples/xml/saxbookmarks/saxbookmarks.pro index 7293bd1..d4b09b6 100644 --- a/examples/xml/saxbookmarks/saxbookmarks.pro +++ b/examples/xml/saxbookmarks/saxbookmarks.pro @@ -14,7 +14,7 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/xml/saxbookmarks INSTALLS += target sources wince*: { - addFiles.sources = frank.xbel jennifer.xbel + addFiles.files = frank.xbel jennifer.xbel addFiles.path = "\\My Documents" DEPLOYMENT += addFiles } @@ -22,7 +22,7 @@ wince*: { symbian: { TARGET.UID3 = 0xA000C60A include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - addFiles.sources = frank.xbel jennifer.xbel + addFiles.files = frank.xbel jennifer.xbel addFiles.path = /data/qt/saxbookmarks DEPLOYMENT += addFiles } diff --git a/examples/xmlpatterns/recipes/querymainwindow.cpp b/examples/xmlpatterns/recipes/querymainwindow.cpp index 0fd2483..8a4c606 100644 --- a/examples/xmlpatterns/recipes/querymainwindow.cpp +++ b/examples/xmlpatterns/recipes/querymainwindow.cpp @@ -49,10 +49,10 @@ QueryMainWindow::QueryMainWindow() : ui_defaultQueries(0) { setupUi(this); - new XmlSyntaxHighlighter(qFindChild<QTextEdit*>(this, "inputTextEdit")->document()); - new XmlSyntaxHighlighter(qFindChild<QTextEdit*>(this, "outputTextEdit")->document()); + new XmlSyntaxHighlighter(findChild<QTextEdit*>("inputTextEdit")->document()); + new XmlSyntaxHighlighter(findChild<QTextEdit*>("outputTextEdit")->document()); - ui_defaultQueries = qFindChild<QComboBox*>(this, "defaultQueries"); + ui_defaultQueries = findChild<QComboBox*>("defaultQueries"); QMetaObject::connectSlotsByName(this); connect(ui_defaultQueries, SIGNAL(currentIndexChanged(int)), SLOT(displayQuery(int))); @@ -71,7 +71,7 @@ void QueryMainWindow::displayQuery(int index) QFile queryFile(QString(":files/") + ui_defaultQueries->itemText(index)); queryFile.open(QIODevice::ReadOnly); const QString query(QString::fromLatin1(queryFile.readAll())); - qFindChild<QTextEdit*>(this, "queryTextEdit")->setPlainText(query); + findChild<QTextEdit*>("queryTextEdit")->setPlainText(query); evaluate(query); } @@ -90,7 +90,7 @@ void QueryMainWindow::loadInputFile() QTextStream in(&forView); QString inputDocument = in.readAll(); - qFindChild<QTextEdit*>(this, "inputTextEdit")->setPlainText(inputDocument); + findChild<QTextEdit*>("inputTextEdit")->setPlainText(inputDocument); } @@ -116,7 +116,7 @@ void QueryMainWindow::evaluate(const QString &str) return; buffer.close(); - qFindChild<QTextEdit*>(this, "outputTextEdit")->setPlainText(QString::fromUtf8(outArray.constData())); + findChild<QTextEdit*>("outputTextEdit")->setPlainText(QString::fromUtf8(outArray.constData())); } //! [2] |