From 37a8e98cd004601623476fc0a390fc156c0b52f5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 13 Sep 2011 14:43:51 +0200 Subject: Add QtUiTools and uilib This code used to live in qtbase. It doesn't belong there however and since there are no dependencies in qtbase left that require it move it here. This significantly simplifies the build system with regards to the code in uilib. Change-Id: I41c8687bd071a1c253eb55594986f3e1424bc6cf Reviewed-on: http://codereview.qt-project.org/4830 Reviewed-by: Lars Knoll --- examples/examples.pro | 2 +- .../uitools/multipleinheritance/calculatorform.cpp | 65 +++++ .../uitools/multipleinheritance/calculatorform.h | 62 +++++ .../uitools/multipleinheritance/calculatorform.ui | 303 +++++++++++++++++++++ examples/uitools/multipleinheritance/main.cpp | 56 ++++ .../multipleinheritance.desktop | 11 + .../multipleinheritance/multipleinheritance.pro | 19 ++ examples/uitools/textfinder/main.cpp | 55 ++++ examples/uitools/textfinder/textfinder.cpp | 155 +++++++++++ examples/uitools/textfinder/textfinder.desktop | 11 + examples/uitools/textfinder/textfinder.h | 74 +++++ examples/uitools/textfinder/textfinder.pro | 17 ++ examples/uitools/textfinder/textfinder.qrc | 6 + examples/uitools/uitools.pro | 14 + 14 files changed, 849 insertions(+), 1 deletion(-) create mode 100644 examples/uitools/multipleinheritance/calculatorform.cpp create mode 100644 examples/uitools/multipleinheritance/calculatorform.h create mode 100644 examples/uitools/multipleinheritance/calculatorform.ui create mode 100644 examples/uitools/multipleinheritance/main.cpp create mode 100644 examples/uitools/multipleinheritance/multipleinheritance.desktop create mode 100644 examples/uitools/multipleinheritance/multipleinheritance.pro create mode 100644 examples/uitools/textfinder/main.cpp create mode 100644 examples/uitools/textfinder/textfinder.cpp create mode 100644 examples/uitools/textfinder/textfinder.desktop create mode 100644 examples/uitools/textfinder/textfinder.h create mode 100644 examples/uitools/textfinder/textfinder.pro create mode 100644 examples/uitools/textfinder/textfinder.qrc create mode 100644 examples/uitools/uitools.pro (limited to 'examples') diff --git a/examples/examples.pro b/examples/examples.pro index e2f2c617f..3c12ee67c 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS += help designer +SUBDIRS += help designer uitools diff --git a/examples/uitools/multipleinheritance/calculatorform.cpp b/examples/uitools/multipleinheritance/calculatorform.cpp new file mode 100644 index 000000000..ae1312f55 --- /dev/null +++ b/examples/uitools/multipleinheritance/calculatorform.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 +#include "calculatorform.h" + + +//! [0] +CalculatorForm::CalculatorForm(QWidget *parent) + : QWidget(parent) +{ + setupUi(this); +} +//! [0] + +//! [1] +void CalculatorForm::on_inputSpinBox1_valueChanged(int value) +{ + outputWidget->setText(QString::number(value + inputSpinBox2->value())); +} +//! [1] + +//! [2] +void CalculatorForm::on_inputSpinBox2_valueChanged(int value) +{ + outputWidget->setText(QString::number(value + inputSpinBox1->value())); +} +//! [2] diff --git a/examples/uitools/multipleinheritance/calculatorform.h b/examples/uitools/multipleinheritance/calculatorform.h new file mode 100644 index 000000000..9b8c8880b --- /dev/null +++ b/examples/uitools/multipleinheritance/calculatorform.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 CALCULATORFORM_H +#define CALCULATORFORM_H + +//! [0] +#include "ui_calculatorform.h" +//! [0] + +//! [1] +class CalculatorForm : public QWidget, private Ui::CalculatorForm +{ + Q_OBJECT + +public: + CalculatorForm(QWidget *parent = 0); + +private slots: + void on_inputSpinBox1_valueChanged(int value); + void on_inputSpinBox2_valueChanged(int value); +}; +//! [1] + +#endif diff --git a/examples/uitools/multipleinheritance/calculatorform.ui b/examples/uitools/multipleinheritance/calculatorform.ui new file mode 100644 index 000000000..dda0e62dd --- /dev/null +++ b/examples/uitools/multipleinheritance/calculatorform.ui @@ -0,0 +1,303 @@ + + + + + CalculatorForm + + + CalculatorForm + + + + 0 + 0 + 276 + 98 + + + + + 5 + 5 + 0 + 0 + + + + Calculator Builder + + + + + + + 9 + + + 6 + + + + + + + + 1 + + + 6 + + + + + + + + 1 + + + 6 + + + + + label + + + + 1 + 1 + 45 + 19 + + + + Input 1 + + + + + + + inputSpinBox1 + + + + 1 + 26 + 45 + 25 + + + + true + + + + + + + + + label_3 + + + + 54 + 1 + 7 + 52 + + + + + + + + Qt::AlignCenter + + + + + + + + + + 1 + + + 6 + + + + + label_2 + + + + 1 + 1 + 45 + 19 + + + + Input 2 + + + + + + + inputSpinBox2 + + + + 1 + 26 + 45 + 25 + + + + true + + + + + + + + + label_3_2 + + + + 120 + 1 + 7 + 52 + + + + = + + + Qt::AlignCenter + + + + + + + + + + 1 + + + 6 + + + + + label_2_2_2 + + + + 1 + 1 + 37 + 17 + + + + Output + + + + + + + outputWidget + + + + 1 + 24 + 37 + 27 + + + + QFrame::Box + + + QFrame::Sunken + + + 0 + + + Qt::AlignAbsolute|Qt::AlignBottom|Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignHorizontal_Mask|Qt::AlignJustify|Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing|Qt::AlignVCenter|Qt::AlignVertical_Mask + + + + + + + + + + + verticalSpacer + + + + 85 + 69 + 20 + 20 + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + horizontalSpacer + + + + 188 + 26 + 79 + 20 + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + diff --git a/examples/uitools/multipleinheritance/main.cpp b/examples/uitools/multipleinheritance/main.cpp new file mode 100644 index 000000000..56ba8efe5 --- /dev/null +++ b/examples/uitools/multipleinheritance/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 +#include "calculatorform.h" + +//! [0] +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + CalculatorForm calculator; +#if defined(Q_OS_SYMBIAN) + calculator.showMaximized(); +#else + calculator.show(); +#endif + return app.exec(); +} +//! [0] diff --git a/examples/uitools/multipleinheritance/multipleinheritance.desktop b/examples/uitools/multipleinheritance/multipleinheritance.desktop new file mode 100644 index 000000000..7e652f972 --- /dev/null +++ b/examples/uitools/multipleinheritance/multipleinheritance.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Multiple Inheritance +Exec=/opt/usr/bin/multipleinheritance +Icon=multipleinheritance +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/uitools/multipleinheritance/multipleinheritance.pro b/examples/uitools/multipleinheritance/multipleinheritance.pro new file mode 100644 index 000000000..7e6496741 --- /dev/null +++ b/examples/uitools/multipleinheritance/multipleinheritance.pro @@ -0,0 +1,19 @@ +#! [0] +SOURCES = calculatorform.cpp main.cpp +HEADERS = calculatorform.h +FORMS = calculatorform.ui +#! [0] + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/uitools/multipleinheritance +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/uitools/multipleinheritance +INSTALLS += target sources + +symbian { + TARGET.UID3 = 0xA000D7C1 + CONFIG += qt_example +} +QT += widgets +maemo5: CONFIG += qt_example + diff --git a/examples/uitools/textfinder/main.cpp b/examples/uitools/textfinder/main.cpp new file mode 100644 index 000000000..2fe9b715d --- /dev/null +++ b/examples/uitools/textfinder/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 +#include "textfinder.h" + +//! [0] +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(textfinder); + QApplication app(argc, argv); + + TextFinder *textFinder = new TextFinder; + textFinder->show(); + + return app.exec(); +} +//! [0] diff --git a/examples/uitools/textfinder/textfinder.cpp b/examples/uitools/textfinder/textfinder.cpp new file mode 100644 index 000000000..041c36f21 --- /dev/null +++ b/examples/uitools/textfinder/textfinder.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 +#include +#include "textfinder.h" + +//! [0] +TextFinder::TextFinder(QWidget *parent) + : QWidget(parent) +{ + QWidget *formWidget = loadUiFile(); + +//! [1] + ui_findButton = findChild("findButton"); + ui_textEdit = findChild("textEdit"); + ui_lineEdit = findChild("lineEdit"); +//! [0] //! [1] + +//! [2] + QMetaObject::connectSlotsByName(this); +//! [2] + +//! [3a] + loadTextFile(); +//! [3a] + +//! [3b] + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(formWidget); + setLayout(layout); +//! [3b] + +//! [3c] + setWindowTitle(tr("Text Finder")); + isFirstTime = true; +} +//! [3c] + +//! [4] +QWidget* TextFinder::loadUiFile() +{ + QUiLoader loader; + + QFile file(":/forms/textfinder.ui"); + file.open(QFile::ReadOnly); + + QWidget *formWidget = loader.load(&file, this); + file.close(); + + return formWidget; +} +//! [4] + +//! [5] +void TextFinder::loadTextFile() +{ + QFile inputFile(":/forms/input.txt"); + inputFile.open(QIODevice::ReadOnly); + QTextStream in(&inputFile); + QString line = in.readAll(); + inputFile.close(); + + ui_textEdit->append(line); + ui_textEdit->setUndoRedoEnabled(false); + ui_textEdit->setUndoRedoEnabled(true); +} +//! [5] + +//! [6] //! [7] +void TextFinder::on_findButton_clicked() +{ + QString searchString = ui_lineEdit->text(); + QTextDocument *document = ui_textEdit->document(); + + bool found = false; + + if (isFirstTime == false) + document->undo(); + + if (searchString.isEmpty()) { + QMessageBox::information(this, tr("Empty Search Field"), + "The search field is empty. Please enter a word and click Find."); + } else { + + QTextCursor highlightCursor(document); + QTextCursor cursor(document); + + cursor.beginEditBlock(); +//! [6] + + QTextCharFormat plainFormat(highlightCursor.charFormat()); + QTextCharFormat colorFormat = plainFormat; + colorFormat.setForeground(Qt::red); + + while (!highlightCursor.isNull() && !highlightCursor.atEnd()) { + highlightCursor = document->find(searchString, highlightCursor, QTextDocument::FindWholeWords); + + if (!highlightCursor.isNull()) { + found = true; + highlightCursor.movePosition(QTextCursor::WordRight, + QTextCursor::KeepAnchor); + highlightCursor.mergeCharFormat(colorFormat); + } + } + +//! [8] + cursor.endEditBlock(); +//! [7] //! [9] + isFirstTime = false; + + if (found == false) { + QMessageBox::information(this, tr("Word Not Found"), + "Sorry, the word cannot be found."); + } + } +} +//! [8] //! [9] diff --git a/examples/uitools/textfinder/textfinder.desktop b/examples/uitools/textfinder/textfinder.desktop new file mode 100644 index 000000000..e1911cc61 --- /dev/null +++ b/examples/uitools/textfinder/textfinder.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Text Finder +Exec=/opt/usr/bin/textfinder +Icon=textfinder +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/uitools/textfinder/textfinder.h b/examples/uitools/textfinder/textfinder.h new file mode 100644 index 000000000..c3cd030cb --- /dev/null +++ b/examples/uitools/textfinder/textfinder.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 TEXTFINDER_H +#define TEXTFINDER_H + +#include + +QT_BEGIN_NAMESPACE +class QPushButton; +class QTextEdit; +class QLineEdit; +QT_END_NAMESPACE + +//! [0] +class TextFinder : public QWidget +{ + Q_OBJECT + +public: + TextFinder(QWidget *parent = 0); + +private slots: + void on_findButton_clicked(); + +private: + QWidget* loadUiFile(); + void loadTextFile(); + + QPushButton *ui_findButton; + QTextEdit *ui_textEdit; + QLineEdit *ui_lineEdit; + bool isFirstTime; +}; +//! [0] + +#endif diff --git a/examples/uitools/textfinder/textfinder.pro b/examples/uitools/textfinder/textfinder.pro new file mode 100644 index 000000000..337b7216e --- /dev/null +++ b/examples/uitools/textfinder/textfinder.pro @@ -0,0 +1,17 @@ +CONFIG += uitools +HEADERS = textfinder.h +RESOURCES = textfinder.qrc +SOURCES = textfinder.cpp main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/uitools/textfinder +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro forms +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/uitools/textfinder +INSTALLS += target sources + +symbian: CONFIG += qt_example +QT += widgets +maemo5: CONFIG += qt_example + +symbian: warning(This example does not work on Symbian platform) +simulator: warning(This example does not work on Simulator platform) diff --git a/examples/uitools/textfinder/textfinder.qrc b/examples/uitools/textfinder/textfinder.qrc new file mode 100644 index 000000000..a4cea8a77 --- /dev/null +++ b/examples/uitools/textfinder/textfinder.qrc @@ -0,0 +1,6 @@ + + + forms/textfinder.ui + forms/input.txt + + \ No newline at end of file diff --git a/examples/uitools/uitools.pro b/examples/uitools/uitools.pro new file mode 100644 index 000000000..f17de666f --- /dev/null +++ b/examples/uitools/uitools.pro @@ -0,0 +1,14 @@ +TEMPLATE = subdirs +SUBDIRS = multipleinheritance + +!wince*:!symbian:contains(QT_BUILD_PARTS, tools): SUBDIRS += textfinder + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/uitools +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS uitools.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/uitools +INSTALLS += target sources + +symbian: CONFIG += qt_example +QT += widgets +maemo5: CONFIG += qt_example -- cgit v1.2.3