diff --git a/dist/changes-5.6.3 b/dist/changes-5.6.3 new file mode 100644 index 0000000000000000000000000000000000000000..501c07a8b0cad7ed96eb81317d680fde98e80ebc --- /dev/null +++ b/dist/changes-5.6.3 @@ -0,0 +1,25 @@ +Qt 5.6.3 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.6.0. + +For more details, refer to the documentation included in this distribution. +The documentation is also available online: + + https://doc.qt.io/qt-5.6/ + +The Qt version 5.6 series is binary compatible with the 5.5.x series. +Applications compiled for 5.5 will continue to run with 5.6. + +Some of the changes listed in this file may include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* General * +**************************************************************************** + + - Fixed several instances of missing, incorrect or obsolete information. + - Updated documentation on supported compilers on Windows 10. diff --git a/dist/changes-5.9.2 b/dist/changes-5.9.2 new file mode 100644 index 0000000000000000000000000000000000000000..57c003a7d3f65ba85b47fada59d59649b00490f9 --- /dev/null +++ b/dist/changes-5.9.2 @@ -0,0 +1,30 @@ +Qt 5.9.2 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.9.0. + +For more details, refer to the documentation included in this distribution. +The documentation is also available online: + +https://doc.qt.io/qt-5/ + +The Qt version 5.9 series is binary compatible with the 5.8.x series. +Applications compiled for 5.8 will continue to run with 5.9. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Qt 5.9.2 Changes * +**************************************************************************** + + - Added documentation on expressing supported Apple OS version in + application projects. + - Updated the tutorial for Getting Started on Qt Widgets. + - Updated documentation on Qt Platform Abstraction and added a list of + QPA plugins. + - Updated description of Qt features in Qt Configure Options. + - Fixed several instances of missing, incorrect, or obsolete information. diff --git a/doc/src/examples.qdoc b/doc/src/examples.qdoc index a84df26f26e7a764b14be156b00b4ce6bcd8c445..54ef66be390b7a44459ddf51e22694d958da80e0 100644 --- a/doc/src/examples.qdoc +++ b/doc/src/examples.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -66,8 +66,8 @@ \list \li \l{Qt Creator: Building for Multiple Platforms}{Building for Multiple Platforms} \li \l{Qt Creator: Running on Multiple Platforms}{Running on Multiple Platforms} - \li \l{Qt Creator: Deploying to Mobile Devices}{Deploying to Mobile Devices} - \li \l{Qt Creator: Connecting Mobile Devices}{Connecting Mobile Devices} + \li \l{Qt Creator: Deploying to Devices}{Deploying to Devices} + \li \l{Qt Creator: Connecting Devices}{Connecting Devices} \endlist \list \li \l{Qt Creator: Building and Running}{See more} diff --git a/doc/src/getting-started/gettingstarted.qdoc b/doc/src/getting-started/gettingstarted.qdoc index d9a5efea2e1603468cba945c8f5c8ca7c278c2d6..c732da6779875063e2eac40b50afedc60dd3596b 100644 --- a/doc/src/getting-started/gettingstarted.qdoc +++ b/doc/src/getting-started/gettingstarted.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -129,8 +129,8 @@ \list \li \l{Qt Creator: Building for Multiple Platforms}{Building for Multiple Platforms} \li \l{Qt Creator: Running on Multiple Platforms}{Running on Multiple Platforms} - \li \l{Qt Creator: Deploying to Mobile Devices}{Deploying to Mobile Devices} - \li \l{Qt Creator: Connecting Mobile Devices}{Connecting Mobile Devices} + \li \l{Qt Creator: Deploying to Devices}{Deploying to Devices} + \li \l{Qt Creator: Connecting Devices}{Connecting Devices} \endlist \list \li \l{Qt Creator: Building and Running}{See more} diff --git a/doc/src/getting-started/gettingstartedqt.qdoc b/doc/src/getting-started/gettingstartedqt.qdoc index 73e3a2a2086136bc3a5926d4d97c041ea46f1328..7c448c28c98286208c233c065685e93a0f00ff5f 100644 --- a/doc/src/getting-started/gettingstartedqt.qdoc +++ b/doc/src/getting-started/gettingstartedqt.qdoc @@ -31,22 +31,11 @@ \title Getting Started Programming with Qt Widgets In this topic, we teach basic Qt knowledge by implementing a simple Notepad - application using C++ and the \l{Qt Widgets} module. We use the - Qt Creator IDE and Qt Designer to generate some code, but you could also write all the - code yourself. + application using C++ and the \l{Qt Widgets} module. The application is a + small text editor which allows you to create a text file, save it, print it, + or reopen and edit it again. You can also set the font to be used. - After reading this topic, you are ready to refer to our overviews and API - documentation, to find the information you need for the application you are - developing. - - In this topic, we first use Qt Creator to create a project with the - necessary files. Then we use Qt Designer to modify the user interface files - to show a text edit and a push button in a window on the desktop. - This represents a simple Qt application that has a GUI. Finally, we add - user interaction to the application by creating actions for opening and - saving files. - - \image gs1.png "Notepad application" + \image notepad1.png "Notepad application" You can find the final Notepad source files in the qtdoc repository in the snippets/widgets-tutorial/notepad directory. You can either fetch @@ -59,14 +48,14 @@ to enter the settings needed for that particular type of project and creates the project for you. - \image gs-project1.png "Qt Creator New File or Project dialog" + \image notepad2.png "Qt Creator New File or Project dialog" To create the Notepad project, select \b File > \b{New File or Project} > \b Applications > \b {Qt Widgets Application} > \b Choose, and follow the instructions of the wizard. In the \b {Class Information} dialog, type \b Notepad as the class name and select \b QMainWindow as the base class. - \image gs-project2.png "Class Information Dialog" + \image notepad3.png "Class Information Dialog" The \b {Qt Widgets Application} wizard creates a project that contains a main source file and a set of files that specify a user interface (Notepad @@ -107,7 +96,7 @@ \snippet snippets/widgets-tutorial/notepad/main.cpp all - Let us go through the code line by line. The following lines include + We will go through the code line by line. The following lines include the header files for the Notepad widget and QApplication. All Qt classes have a header file named after them. @@ -120,9 +109,9 @@ The following line creates a QApplication object. This object manages application-wide resources and is necessary to run any Qt program - that uses Qt Widgets. It constructs an application object with \c argc command - line arguments run in \c argv. (For GUI applications that do not use Qt Widgets, you can use - QGuiApplication instead.) + that uses Qt Widgets. It constructs an application object with \c argc + command line arguments run in \c argv. (For GUI applications that do not + use Qt Widgets, you can use QGuiApplication instead.) \snippet snippets/widgets-tutorial/notepad/main.cpp 3 @@ -137,12 +126,10 @@ \snippet snippets/widgets-tutorial/notepad/main.cpp 4 The following line shows the Notepad widget on the screen in its own - window. - Since widgets also function as containers (for instance a - QMainWindow, which has toolbars, menus, a status bar, and a few - other widgets), it is possible to show a single widget in its own - window. Widgets are not visible by default; the function - \l{QWidget::}{show()} makes the widget visible. + window. Widgets can also function as containers. An example of this + is QMainWindow which often contains several types of widgets. Widgets + are not visible by default; the function \l{QWidget::}{show()} makes + the widget visible. \snippet snippets/widgets-tutorial/notepad/main.cpp 5 @@ -169,7 +156,7 @@ \section1 Designing a UI - The wizard generates a user interface definition in XML format, notepad.ui. + The wizard generates a user interface definition in XML format: notepad.ui. When you open the notepad.ui file in Qt Creator, it automatically opens in the integrated Qt Designer. @@ -180,29 +167,17 @@ \section2 Using Qt Designer The wizard creates an application that uses a QMainWindow. It has its own - layout to which you can add a menu bar, dock widgets, tool bars, and a + layout to which you can add a menu bar, dock widgets, toolbars, and a status bar. The center area can be occupied by any kind of widget. The wizard places the Notepad widget there. - Let us use Qt Designer to add a QTextEdit object and a QPushButton object to - the main window. When you type text in the text edit widget, it receives key - pressed events and responds by drawing the text typed. The button will exit - the Notepad application when pushed (that is, clicked with the mouse). - To add widgets in Qt Designer: \list 1 \li In the Qt Creator \b Editor mode, double-click the notepad.ui file in the \b Projects view to launch the file in the integrated Qt Designer. - \li Drag and drop the following widgets to the form: - \list - \li Text Edit (QTextEdit) - \li Push Button (QPushButton) - \endlist - \li Double-click the \b {Push Button} widget and enter the text \b Quit. - \li In the \b Properties pane, change the value of \b objectName to - \b quitButton. + \li Drag and drop widgets Text Edit (QTextEdit) to the form. \li Press \b {Ctrl+A} (or \b {Cmd+A}) to select the widgets and click \b {Lay out Vertically} (or press \b {Ctrl+L}) to apply a vertical layout (QVBoxLayout). @@ -211,7 +186,7 @@ The UI now looks as follows in Qt Designer: - \image gs2.png + \image notepad4.png You can view the generated XML file in the code editor: @@ -234,28 +209,6 @@ <ui version="4.0"> \endcode - The following snippet creates a QVBoxLayout widget that contains a QTextEdit - and QPushButton widget. As mentioned, widgets can contain - other widgets. It is possible to set the bounds (the location and - size) of child widgets directly, but it is usually easier to use a - layout. A layout manages the bounds of a widget's children. - QVBoxLayout, for instance, places the children in a vertical row. - - \code - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTextEdit" name="textEdit"/> - </item> - <item> - <widget class="QPushButton" name="quitButton"> - <property name="text"> - <string>Quit</string> - </property> - </widget> - </item> - </layout> - \endcode - The UI file is used together with the header and source file of the Notepad class. We will look at the rest of the UI file in the later sections. @@ -282,7 +235,7 @@ definition, and declares our class as a QObject. Naturally, it must also inherit from QObject. A QObject adds several abilities to a normal C++ class. Notably, the class name and slot names can be - queried at run-time. It is also possible to query a slot's + queried at runtime. It is also possible to query a slot's parameter types and invoke it. \snippet snippets/gs/notepad1.h 3 @@ -343,6 +296,11 @@ \snippet snippets/gs/notepad1.cpp 5 + In order to have the text edit field occupy the whole screen, we add + \c setCentralWidget to the main window. + + \snippet snippets/widgets-tutorial/notepad/notepad.cpp 1 + \section2 Project File The wizard generates the following project file, \c {notepad.pro}, for us: @@ -389,179 +347,129 @@ \section1 Adding User Interaction - We now have a user interface, but it does not really do anything useful, as - it only contains a text edit and a push button, as well as some standard - functions for quitting, minimizing and maximizing the application. To make - the application useful, we will add user interaction to it. First, we will - add functionality to the push button. Second, we will add functions for - loading a file to the text edit and for saving the contents of the text edit - as a file. - - \section2 Adding Push Buttons - - Most desktop operating systems have standard ways of enabling users to quit - applications. However, in this example we use this basic function to - illustrate how you can add user interaction to applications. To do this, we - add a slot that we connect to the \b {Quit button}. - - To exit the application when the \b Quit button is pushed, you use the Qt - signals and slots mechanism. A signal is emitted when a particular event - occurs and a slot is a function that is called in response to a particular - signal. Qt widgets have predefined signals and slots that you can use - directly from Qt Designer. - - To use Qt Designer to add a slot for the quit function, right-click the - \b Quit button to open a context-menu and then select \b {Go to slot} > - \b {clicked()}. - - A private slot, \c{on_quitButton_clicked()}, is added to the Notepad widget - class header file, notepad.h and a private function, - \c{Notepad::on_quitButton_clicked()}, is added to the Notepad widget class - source file, notepad.cpp. We just need to write the code to execute the quit - function in the source file. - - Let us look at the modified code in the header file, notepad.h: - - \snippet snippets/gs/notepad2.h all - - The following code uses Qt's signals and slots mechanism to make the - application exit when the \b {Quit button} is pushed. Qt Designer uses - QMetaObject \l{designer-using-a-ui-file.html#automatic-connections} - {auto-connection facilities} to connect the button's clicked() signal to a - slot in the Notepad class. The \c uic tool automatically generates code in - the dialog's \c{setupUi()} function to do this, so Qt Designer only needs to - declare and implement a slot with a name that follows a standard convention. - - \snippet snippets/gs/notepad2.h 1 - The corresponding code in the source file, notepad.cpp, looks as follows: + To add functionality to the editor, we start by adding menu items and buttons on a toolbar. - \snippet snippets/gs/notepad2.cpp all + Click on "Type Here", and add the options New, Open, Save, Save as, Print + and Exit. This creates 5 lines in the Action Editor below. To connect the + actions to slots, right-click an action and select Go to slot > triggered(), + and complete the code for that given slot. - The code defines the private function that is executed when QPushButton - emits the \l{QPushButton::}{clicked()} signal. + If we also want to add the actions to a toolbar, we can assign an icon + to each QAction, and then drag the QAction to the toolbar. You assign an icon + by entering an icon name in the Icon property of the action concerned. When the QAction + has been dragged to the toolbar, clicking the icon will launch the associated + slot. - We now complement the code to have the \l{QCoreApplication::}{quit()} slot of - QApplication exit Notepad: + Complete the method \c on_actionNew_triggered() : - \snippet snippets/widgets-tutorial/notepad/notepad.cpp 1 - - \b{Learn More} - - \table - \header - \li About - \li Here - \row - \li Signals and slots - \li \l{Signals & Slots} - \endtable + \snippet snippets/widgets-tutorial/notepad/notepad.cpp 2 - \section2 Adding Menu Items + \c current_file is a global variable containing the file presently being edited. + It is defined in the private part of notepad.h: - Often, in a main window, the same slot should be invoked by - several widgets. Examples are menu items and buttons on a tool - bar. To make this easier, Qt provides QAction, which can be given - to several widgets, and be connected to a slot. For instance, both - QMenu and QToolBar can create menu items and tool buttons from the - same \l{QAction}. + \snippet snippets/widgets-tutorial/notepad/notepad.h 6 - To learn how to use actions with signals and slots, we add menu items to - open and save a document and connect them to slots. + \c setText("") clears the text buffer. - As before, we use Qt Designer to add the widgets to the user interface. - The wizard creates an application with a QMenu widget, with the text - \b {Type Here} as a placeholder for menu and menu item names. Double-click - the text to enter names for the \b File menu and \b Open and \b Save menu - items. Qt Designer automatically generates the appropriate actions. + \section2 Opening a file - \image gs3.png + In \c notepad.ui, right click on \c actionOpen and select \c {Go to slot} - To connect the actions to slots, right-click an action and select - \b {Go to slot} > \b triggered(). + Complete method \c on_actionOpen_triggered(). - \l{QAction} instances are created with the text that should appear on the - widgets that we add them to (in our case, menu items). If we also - wanted to add the actions to a tool bar, we could have specified - \l{QIcon}{icons} for them. + \snippet snippets/widgets-tutorial/notepad/notepad.cpp 3 - The modified code in notepad.ui now looks as follows: + \c QFileDialog::getOpenFileName opens a dialog enabling you to select a file. + QFile object \c myfile has the selected \c file_name as parameter. + We store the selected file also into the global variable \c current_file for later purposes. + We open the file with \c file.open as a readonly text file. If it + cannot be opened, a warning is issued, and the program stops. - \quotefromfile snippets/widgets-tutorial/notepad/notepad.ui + We define a QTextStream \c instream for parameter \c myfile. + The contents of file \c myfile is copied into QString \a text. + \c setText(text) fille the buffer of our editor with \c text. - \skipto QMenuBar - \printto layoutdefault + \c section2 Saving a file - Qt Designer adds the private slots \c{on_actionOpen_triggered()} and - \c{on_actionSave_triggered()} to notepad.h and the private functions - \c{Notepad::on_actionOpen_triggered()} and - \c{Notepad::on_actionSave_triggered()} to notepad.cpp. + We create the method for saving a file in the same way as for \l {Opening a file}, + by right clicking on \c actionSave, and selecting \c {Go to Slot}. - In the following sections, we complement the code to load and save files. - When a menu item is clicked, the item triggers the action, and the - respective slot is invoked. + \snippet snippets/widgets-tutorial/notepad/notepad.cpp 4 - \section2 Opening Files + QFile object \c myfile is linked to global variable \c current_file, the variable that + contains the file we were working with. + If we cannot open \c myfile, an error message is issued and the method stops. + We create a QTextStream \c outstream. The contents of the editor buffer is converted + to plain text, and then written to \c outstream. - In this section, we implement the functionality of the - \c{on_actionOpen_triggered()} slot. The first step is asking the user for - the name of the file to open. Qt comes with QFileDialog, which is a dialog - from which the user can select a file. The appearance of the dialog depends - on the desktop platform that you run the application on. The following - image shows the dialog on \macos: + \c section2 Saving a file with \c {Save as} - \image gs4.png + \snippet snippets/widgets-tutorial/notepad/notepad.cpp 5 - We complement the code generated by Qt Designer in notepad.cpp, as follows: + This is the same procedure as for \c {Saving a file}, the only difference + being that here you need to enter a new file name for the file to + be created. - \snippet snippets/widgets-tutorial/notepad/notepad.cpp 2 - The static \l{QFileDialog::}{getOpenFileName()} function - displays a modal file dialog. It returns the file path of the file - selected, or an empty string if the user canceled the dialog. + \section2 Print a file - If we have a file name, we try to open the file with - \l{QIODevice::}{open()}, which returns true if the file could be - opened. We will not go into error handling here, but you can follow - the links from the learn more section. If the file could not be - opened, we use QMessageBox to display a dialog with an error - message (see the QMessageBox class description for further - details). + If you want to use print functionalities, you need to add \c printsupport to + the project file: - Actually reading in the data is trivial using the QTextStream - class, which wraps the QFile object. The - \l{QTextStream::}{readAll()} function returns the contents of the - file as a QString. The contents can then be displayed in the text - edit. We then \l{QIODevice::}{close()} the file to return the file - descriptor back to the operating system. + QT += core gui printsupport - We now use the function \l{QObject::}{tr()} around our user - visible strings. This function is necessary when you want to - provide your application in more than one language (for example, English - and Chinese). We will not go into details here, but you can follow - the \c {Qt Linguist} link from the learn more table. + We declare a QPrinter object called \c printer. + We launch a printer dialog box and store the selected printer in object \c printer. + If we clicked on \c Cancel and did not select a printer, the methods returns. + The actual printer command is given with \a ui->textEdit->print with our QPrinter + object as parameter. - To use QFileDialog, QFile, QMessageBox, and QTextStream, add the following - includes to notepad.cpp: + \section2 Select a font - \snippet snippets/widgets-tutorial/notepad/notepad.cpp 0 + \snippet snippets/widgets-tutorial/notepad/notepad.cpp 7 - \section2 Saving Files + We declare a boolean indicating if we did select a font with QFontDialog. If so, we + set the font with \c ui->textEdit->setFont(myfont). - Now, let us move on to the \c{on_actionSave_triggered()} slot, which - also uses QFileDialog to create a dialog in which the user can save a - file with the specified name in the specified location. + \section2 Copy, cut, paste, undo, redo - \image gs5.png + If you select some text, and want to copy it to the clipboard, + you call the appropriate method of ui->textEdit. The same counts + for cut, paste, undo, and redo. - We complement the code generated by Qt Designer in notepad.cpp, as follows: + This table shows the method name to use. - \snippet snippets/widgets-tutorial/notepad/notepad.cpp 3 + \table + \header + \li Task + \li Method called + \row + \li Copy + \li ui->textEdit->copy() + \row + \li Cut + \li ui->textEdit->cut() + \row + \li Paste + \li ui->textEdit->paste() + \row + \li Undo + \li ui->textEdit->undo() + \row + \li Redo + \li ui->textEdit->redo() + \endtable - When we write the contents of the text edit to the file, we use - the QTextStream class again. QTextStream can also write - \l{QString}s to the file with the << operator. + This project contains the following files: + \list + \li {main.cpp} + \li {notepad.cpp} + \li {notepad.h} + \li {notepad.pro} + \li {notepad.ui} + \endlist \b{Learn More} \table diff --git a/doc/src/images/notepad.png b/doc/src/images/notepad.png new file mode 100644 index 0000000000000000000000000000000000000000..40d13269b9001abb873a5014d46bb100c1010255 Binary files /dev/null and b/doc/src/images/notepad.png differ diff --git a/doc/src/images/notepad1.png b/doc/src/images/notepad1.png new file mode 100644 index 0000000000000000000000000000000000000000..40d13269b9001abb873a5014d46bb100c1010255 Binary files /dev/null and b/doc/src/images/notepad1.png differ diff --git a/doc/src/images/notepad2.png b/doc/src/images/notepad2.png new file mode 100644 index 0000000000000000000000000000000000000000..9cec1f9a581e7d8c547937af9d753526a1324796 Binary files /dev/null and b/doc/src/images/notepad2.png differ diff --git a/doc/src/images/notepad3.png b/doc/src/images/notepad3.png new file mode 100644 index 0000000000000000000000000000000000000000..426861ab0680f1d51d6cb1a323d92d6058025f7c Binary files /dev/null and b/doc/src/images/notepad3.png differ diff --git a/doc/src/images/notepad4.png b/doc/src/images/notepad4.png new file mode 100644 index 0000000000000000000000000000000000000000..fc08eab204e5ae0e17dc750fea8181a463683abe Binary files /dev/null and b/doc/src/images/notepad4.png differ diff --git a/doc/src/images/notepad_menu.png b/doc/src/images/notepad_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..2dd771111a7f24c11a73f1273be45b0bbb7e9f90 Binary files /dev/null and b/doc/src/images/notepad_menu.png differ diff --git a/doc/src/platforms/supported-platforms.qdocinc b/doc/src/platforms/supported-platforms.qdocinc index 21767ee0237a54e4d242079d394d6fdad7982355..239d4293133ad80e20097a45a543144bef2a3a16 100644 --- a/doc/src/platforms/supported-platforms.qdocinc +++ b/doc/src/platforms/supported-platforms.qdocinc @@ -176,7 +176,8 @@ Mobile Platforms: \l {Qt for Android}{Android}, \li \row \li {3,1} \header \li {3,1} - Embedded Platforms: \l {Qt for Embedded Linux}{Embedded Linux}, \l {QNX}, \l {INTEGRITY} + Embedded Platforms: \l {Qt for Embedded Linux}{Embedded Linux}, \l {QNX}, \l {INTEGRITY}, + \l{Qt for VxWorks}{VxWorks} \row \li \l {Qt for Embedded Linux}{Embedded Linux} \li GCC \li ARM Cortex-A, Intel boards with GCC-based toolchains \row \li QNX 6.6.0, 7.0 (armv7le and x86) @@ -186,6 +187,9 @@ Mobile Platforms: \l {Qt for Android}{Android}, \row \li \l {INTEGRITY} {INTEGRITY 11.4.x} \li As provided by Green Hills INTEGRITY \li Hosts: 64-bit Linux + \row \li \l{Qt for VxWorks}{VxWorks 7} + \li As provided by Wind River + \li Hosts: 64-bit Linux, Windows \row \li {3,1} \header \li {3,1} Mobile Platforms: \l {Qt for Android}{Android}, \l {Qt for iOS}{iOS}, diff --git a/doc/src/platforms/vxworks.qdoc b/doc/src/platforms/vxworks.qdoc new file mode 100644 index 0000000000000000000000000000000000000000..7bc891f27d98241e14df110a73324c51d7467f6a --- /dev/null +++ b/doc/src/platforms/vxworks.qdoc @@ -0,0 +1,529 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page vxworks.html + \title Qt for VxWorks + + Qt for VxWorks is available only under a commercial license. + + Contact The Qt Company for more information: + \l {https://www.qt.io/contact-us/} + + \section1 Supported Architectures and VxWorks Releases + + Qt 5.5 is currently tested and supported on VxWorks 7 release SR0480 2016-09-16. + Supported architecture is ARM-v7. + + \section1 Qt for VxWorks Source Package + + Qt for VxWorks is delivered via the \l {Qt Account}, under the name + \b {Qt 5.5.1} > \b {Qt VxWorks Platform Source Package}. + + \section1 Requirements for VxWorks + + \section2 QtWidget Applications + + \list + \li Framebuffer device (FBDEV) + \li Evdev support (compatibility mode) + \li POSIX support + \li C++11 support + \endlist + + \section2 Qt Quick 2 Applications + + All features which are required for QtWidget applications, and in addition the following: + + \list + \li GPU device (GPUDEV) for OpenGL ES 2.0 + \endlist + + \section1 Supported Modules + + Almost all essential \l{All Modules}{Qt modules} and some add-on modules supported. + + \section2 Limitations for Essential modules + + \table 80% + \header + \li Qt Module + \li Supported Features + \li Notes + + \row + \li \l {Qt Multimedia} + \li Audio + \li \l [QML] {QtMultimedia::SoundEffect}{SoundEffect}, + \l [QtMultimedia] {QSound}, + \l [QtMultimedia] {QSoundEffect} and + \l [QtMultimedia] {QAudioOutput} + + \row + \li \l {Qt Multimedia Widgets} + \li Not supported + \li + + \row + \li Qt WebKit + \li Not supported + \li + + \row + \li Qt WebKit Widgets + \li Not supported + \li + + \endtable + + \section2 Supported Add-ons + + \table 80% + \header + \li Qt Add-on + \li Notes + \row + \li \l {Qt Charts} + \li Version 2.0.1 + \row + \li \l {Qt Data Visualization} + \li Version 1.2.1 + \row + \li \l {Qt Virtual Keyboard} + \li Version 2.0 + \row + \li \l {Qt Quick Compiler} + \li Version 3.0 + \row + \li \l {Qt Concurrent} + \li + \row + \li \l {Qt Graphical Effects} + \li + \row + \li \l {Qt Image Formats} + \li + \row + \li \l {Qt OpenGL} + \li Only OpenGL ES 2 \note Provided to ease porting from Qt 4.x. + Use the QOpenGL classes in \l{Qt GUI} for new code + \row + \li \l {Qt Platform Headers} + \li + \row + \li \l {Qt SVG} + \li + \row + \li \l {Qt XML Patterns} + \li + \endtable + + \note You can explicitly exclude unsupported or unused modules from the + build via the -skip <module> option when running the configure tool. + + \section1 Platform Notes + + With the release of Qt 5.0, Qt no longer contains its own window system + implementation: QWS is no longer a supported platform. For single-process use + cases, the \l{Qt Platform Abstraction} is a superior solution. + + There are two platform plugins that are usable on VxWorks: EGLFS and VxWorksFB. + The availability of these plugins depends on the configuration of Qt. The default + platform plugin is also device-specific. For instance, on many boards \c eglfs will be + chosen as the default one. If the default is not suitable, the \c QT_QPA_PLATFORM + environment variable parameter can be used to request another plugin. + Alternatively, for quick tests, the \c -platform command-line option can be used + with the same syntax. + + \section1 Configuring for a Specific Device + + Building Qt for a given device requires a toolchain and a + sysroot. Additionally, some devices require vendor specific adaptation code + for EGL and OpenGL ES 2.0 support. This is not relevant for non-accelerated + platforms, for example the ones using the VxWorksFB plugin, however neither + OpenGL nor Qt Quick 2 will be functional in such a setup. + + The directory \e qtbase/mkspecs/devices contains configuration and graphics + adaptation code for a number of devices. For example, \c vxworks-imx6 + contains build settings, such as the optimal compiler and linker flags, for + the \l {http://en.wikipedia.org/wiki/I.MX#i.MX6x_series}{Freescale iMX6 series}, + and either an implementation of the eglfs hooks (vendor-specific adaptation code), + or a reference to a suitable eglfs device integration plugin. The device is + selected through the \l{Qt Configure Options}{configure} tool's \c -device + parameter. The name that follows after this argument must, at least partially, + match one of the subdirectories under \e devices. + + Before running configure and building Qt 5 it is required to open \e {VxWorks 7 + Development Shell} in command prompt. + + \list + \li Linux: + \badcode + cd <VxWorks 7 installation directory> + ./wrenv.sh -p vxworks-7 + \endcode + + \li Windows: + \badcode + cd <VxWorks 7 installation directory> + wrenv -p vxworks-7 + \endcode + \endlist + + Below is an example configuration for the BD-SL-i.MX6. For most VxWorks boards + the configure command will look very similar. By default, Qt 5 is configured to + use shared libraries. To build Qt 5 statically, add \c -static option for configure. + + \badcode + ./configure -commercial -confirm-license -device vxworks-imx6 -device-option CROSS_COMPILE=arm -prefix /sd0:1/qt5rtp -sysroot <path_to_vxworks_vsb_dir>/fsl_imx6_1_1_6_0_VSB -no-gcc-sysroot -extprefix <path_to_host_dir>/qt5rtp -hostprefix <path_to_host_dir>/qt5rtp -no-openssl -nomake tools -nomake examples + \endcode + + The most important parameters are \c -device, \c -device-option CROSS_COMPILE=<arch>, + \c -sysroot and \c -no-gcc-sysroot. By specifying \c -sysroot, the include + files and libraries used by \c {configure}'s feature detection tests, as well + as Qt itself, will be taken from the specified location, instead of the host + PC's standard locations. This means that installing development packages on the + host machine has no relevance. Instead, the headers and the libraries for the + target architecture (e.g. ARM) have to be present in the sysroot. + + It is recommended to build Qt 5 using a \e{shadow build}. See \l {Qt Configure Options} + for more information. + + \section1 Building and Installing Qt 5 + + \badcode + make -j<N> + make install + \endcode + + \section1 Platform Plugins for VxWorks Devices + + \section2 EGLFS + + \l {http://www.khronos.org/egl}{EGL} is an interface between OpenGL and the + native windowing system. Qt can use EGL for context and surface management, + however the API contains no platform specifics: The creation of a \e {native + window} (which will not necessarily be an actual window on the screen) must + still be done by platform-specific means. Hence the need for the board or GPU + specific adaptation code. Such adaptations are provided either as \e {eglfs + hooks}, a single source file compiled in to the platform plugin, or as + dynamically loaded \e {EGL device integration} plugins. + + EGLFS is a platform plugin for running Qt 5 applications on top of EGL and + OpenGL ES 2.0 without an actual windowing system (like X11 or Wayland). In + addition to Qt Quick 2 and native OpenGL applications it supports + software-rendered windows (for example QWidget) too. In the latter case the + widgets' contents are rendered using the CPU into images which are then + uploaded into textures and composited by the plugin. + + This is the recommended plugin for modern VxWorks devices that include + a GPU. + + EGLFS forces the first top-level window (be it either a QWidget or a + QQuickView) to become fullscreen. This window is also chosen to be the \e root + widget window into which all other top-level widgets (for example dialogs, + popup menus or combobox dropdowns) are composited. This is necessary because + with EGLFS there is always exactly one native window and EGL window surface, + and these belong to the widget or window that is created first. This approach + works well when there is a main window that exists for the entire lifetime of + the application and all other widgets are either non top-levels or are created + afterwards, once the main window is shown. + + There are further restrictions for OpenGL-based windows. As of Qt 5.3, eglfs + supports a single, fullscreen GL window (for example, an OpenGL-based QWindow, + a QQuickView or a QGLWidget). Opening additional OpenGL windows or mixing such + windows with QWidget-based content is not supported and will terminate the + application with an error message. + + If necessary, eglfs can be configured via environment variables: + + \list + + \li \c {QT_QPA_EGLFS_FB} - Overrides the framebuffer device. The default is + \c /dev/fb0. On most embedded platforms this is not very relevant because the + framebuffer is used only for querying settings like the display dimensions. + On certain devices however this parameter provides the ability to specify + which display to use in multiple display setups, similarly to the \c fb + parameter in VxWorksFB. + + \li \c {QT_QPA_EGLFS_WIDTH} and \c {QT_QPA_EGLFS_HEIGHT} - Contain the screen + width and height in pixels. While eglfs will try to determine the dimensions + from the framebuffer device \e{/dev/fb0}, this will not always work and + manually specifying the sizes may become necessary. + + \li \c {QT_QPA_EGLFS_PHYSICAL_WIDTH} and \c {QT_QPA_EGLFS_PHYSICAL_HEIGHT} - + Physical screen width and height in millimeters. On platforms where the + framebuffer device \e{/dev/fb0} is not available or the query is not + successful, the values are calculated based on a default DPI of 100. This + variable can be used to override any such defaults. + + \li \c {QT_QPA_EGLFS_DEPTH} - Overrides the color depth for the screen. On + platforms where the framebuffer device \e{/dev/fb0} is not available or the + query is not successful, the default of 32 is used. This variable can be used + to override any such defaults. Note that this affects only the color depth + value reported by QScreen. It has no connection to EGL configurations and the + color depth used for OpenGL rendering. + + \li \c {QT_QPA_EGLFS_SWAPINTERVAL} - By default a swap interval of \c 1 will + be requested. This enables synchronizing to the displays vertical refresh. The + value can be overridden with this environment variable. For instance, passing + 0 will disable blocking on swap, resulting in running as fast as possible + without any synchronization. + + \li \c {QT_QPA_EGLFS_FORCE888} - When set, the red, green and blue color + channel sizes are ignored whenever creating a new context, window or offscreen + surface. Instead, the plugin will request a configuration with 8 bits per + channel. This can be helpful on devices where configurations with less than 32 + or 24 bits per pixel are chosen by default but are known not to be suitable, + for example, due to banding effects. Instead of changing all the applications, + this variable provides an easier shortcut to force 24/32 bpp configurations + for a given device. + + \li \c {QT_QPA_EGLFS_DEBUG} - When set, some debugging information is printed + on the debug output. For example, the input QSurfaceFormat and the properties + of the chosen EGL configuration are printed whenever creating a new + context. Together with Qt Quick's \c {QSG_INFO} variable, this can provide + useful information for troubleshooting issues related to the EGL + configuration. + + \li \c {QT_QPA_EGLFS_INTEGRATION} - In addition to the compiled-in \e hooks, + it is also possible to provide device or vendor-specific adaptation in the + form of dynamically loaded plugins. This environment variable enforces a + specific plugin. For example, setting it to \e{eglfs_kms} will use the KMS/DRM + backend. This is only an option when no static, compiled-in hooks were + specified in the device makespecs. In practice the traditional compiled-in + hooks are rarely used, almost all backends are now migrated to plugins. The + device makespecs still contain a relevant \c EGLFS_DEVICE_INTEGRATION entry: + the name of the preferred backend for that particular device. This is + optional, but very useful to avoid the need to set this environment variable + in case there are more than one plugins present in the target system. In a + desktop environment the KMS or the X11 backends are prioritized, depending on + the presence of the \c DISPLAY environment variable. + + \endlist + + In addition to \c {QT_QPA_EGLFS_DEBUG}, eglfs also supports the more modern + categorized logging system of Qt. The following logging categories are + available: + + \list + + \li \c qt.qpa.egldeviceintegration – Enables logging for dynamically loaded + backends. Very useful to check what backend is in use. + + \li \c qt.qpa.input – Enables debug output from the evdev input handler. + Very useful to check if a given input device was correctly recognized and + opened. + + \endlist + + \section2 Qt Quick Scene Graph Rendering Thread + + The scene graph is a graphical representation of the Item scene. It + can be thought of as a graphical deep copy, an independent structure + that contains enough information to render all the items. + + On many platforms, the \l{Qt Quick Scene Graph}{scene graph} will even be + rendered on a dedicated render thread while the GUI thread is preparing the + next frame's state. + + In some cases when application is complex e.g. it's scene graph contains + lot's of Items, scene graph can consume more stack memory than what is + available by default for the render thread. Default stack memory size is + 64KB. Using the environment variable QSG_RENDERTHREAD_STACK_SIZE, it is possible + to increase the stack size available for the scene graph render thread. + + \section2 VxWorksFB + + This plugin writes directly to the framebuffer. Only software-rendered content + is supported. Note that on some setups the display performance is expected to + be limited. + + The \c vxworksfb plugin allows specifying additional settings by passing them + in the \c QT_QPA_PLATFORM environment variable or \c -platform command-line + option. For example, \c {QT_QPA_PLATFORM=vxworksfb:fb=/dev/fb1} specifies that + the framebuffer device \c /dev/fb1 should be used instead of the default + \c fb0. Multiple settings can be specfified by separating them with a colon. + + \list + + \li \c {fb=/dev/fbN} - Specifies the framebuffer devices. On multiple display + setups this will typically allow running the application on different + displays. For the time being there is no way to use multiple framebuffers from + one Qt application. + + \li \c{size=}\e{<width>}\c{x}\e{<height>} - Specifies the screen size in + pixels. The plugin will try to query the display dimensions, both physical and + logical, from the framebuffer device. This may not always lead to proper + results however, and therefore it may become necessary to explicitly specify + the values. + + \li \c{mmSize=}\e{<width>}\c{x}\e{<height>} - Physical width and height in + millimeters. + + \li \c{offset=}\e{<width>}\c{x}\e{<height>} - Offset in pixels specifying the + top-left corner of the screen. The default position is at \c{(0, 0)}. + + \endlist + + \section1 Input + + When no windowing system is present, the mouse, keyboard and touch input are + read directly via \c evdev. Note that this requires that devices nodes + \c {/input/event*} are readable by the user. eglfs and vxworksfb has all + the evdev input handling code built-in. + + \section2 Input on eglfs and vxworksfb + + Parameters like the device node name can be set in the environment variables + \c QT_QPA_EVDEV_MOUSE_PARAMETERS, \c QT_QPA_EVDEV_KEYBOARD_PARAMETERS and + \c QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS. Additionally, the built-in input handlers + can be disabled by setting \c QT_QPA_EGLFS_DISABLE_INPUT or + \c QT_QPA_FB_DISABLE_INPUT to \c 1. On some touch screens the coordinates will + need to be rotated. This can be enabled by setting + \c QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS to \c {rotate=180}. + + \section2 Mouse + + The mouse cursor will show up whenever \c QT_QPA_EGLFS_HIDECURSOR (for eglfs) + or \c QT_QPA_FB_HIDECURSOR (for vxworksfb) is not set, the mouse cursor will + always show up unless explicitly disabled via the environment variable. + + Hot plugging is not supported. + + \section2 Keyboard + + The evdev keyboard handler supports the following extra parameters: + + \list + + \li \c {/input/...} - Specifies the name of the input device. When not + given, Qt will look for a suitable device by walking through the available + nodes. + \endlist + + If the default, built-in keymap is not sufficient, a different one can be + specified either via the \c keymap parameter or by using the eglfs-specific + \l{QEglFSFunctions::loadKeymap()}{loadKeymap()} function. The latter allows + switching the keymap at runtime. Note however that this requires using eglfs' + built-in keyboard handler; it is not supported when the keyboard handler is + loaded via the \c -plugin command-line parameter. + + \section2 Touch + + Both single and multitouch devices are supported and require that VxWorks + has been properly configured to support touch devices. + + \section2 Debugging Input Devices + + It is possible to print some information to the debug output by enabling + the \c qt.qpa.input logging rule, for example by setting the \c QT_LOGGING_RULES + environment variable to \c{qt.qpa.input=true}. This is useful for detecting + which device is being used, or to troubleshoot device discovery issues. + + \section2 Using Custom Mouse Cursor Images + + eglfs comes with its own set of 32x32 sized mouse cursor images. If these are + not sufficient, a custom cursor atlas can be provided by setting the \c + QT_QPA_EGLFS_CURSOR environment variable to the name of a JSON file. The file + can also be embedded into the application via Qt's resource system. + + For example, an embedded cursor atlas with 8 cursor images per row can be + specified like the following: + + \badcode + { + "image": ":/cursor-atlas.png", + "cursorsPerRow": 8, + "hotSpots": [ + [7, 2], + [12, 3], + [12, 12], + ... + ] + } + \endcode + + Note that the images are expected to be tightly packed in the atlas: the + width and height of the cursors are decided based on the total image size and + the \c cursorsPerRow setting. Atlases have to provide an image for all the + supported cursors. + + \section1 QML Component Loader Thread + + In some cases, a complex application (for example, using a lot of custom + QML components) may cause the QML loader thread to consume stack memory + more than the 32 KB available by default. Using the environment variable + \c QML_LOADERTHREAD_STACK_SIZE, it is possible to increase the stack + size available for the QML loader thread. + + \section1 Preventing Timeouts in QEventDispatcher + + Default system clock rate (SYS_CLK_RATE) for VxWorks 7 is 1/60s or ~16,67ms. + In some cases this may cause a drop in the application frame rate; + in QEventDispatcher, the select function is blocking for the entire system + clock interval because a timeout is used. By defining an environment variable + \c QT_FORCE_SELECT_NOTIMEOUT=1, the select function returns immediately + if no new events are available and the resolution of the system clock is higher + than 10ms, which is true with default value. + + \section1 Running Qt Applications + + Following example shows how to start an application when Qt 5 is built using + shared libraries. With a statically build Qt 5, there is no need to use the + LD_LIBRARY_PATH environment variable. This variable is only needed to point + the location of VxWorks shared libraries (for example libc and OpenGL ES 2.0). + It is not needed for Qt 5 shared libraries. + + \badcode + putenv "LD_LIBRARY_PATH=/sd0:1/lib" + cd "/sd0:1" + rtpSp("<Qt5_app>", 200, 0x100000, 0, 0x01000000) + \endcode + + \section1 Limitations + + \section2 OpenSSL Support + Qt 5 does not support OpenSSL for VxWorks as it does not support using OpenSSL + in RTP mode. + + \section2 Video Memory + + Systems with a fixed amount of dedicated video memory may need extra care + before running Qt application based on Qt Quick or classes like + QOpenGLWidget. The default setting may be insufficient for such applications, + especially when they are displayed on a high resolution (for example, full HD) + screen. In this case they may start failing in unexpected ways. It is + therefore recommended to ensure that there is at least 128 MB of GPU memory + available. For systems that do not have a fixed amount of memory reserved for + the GPU this is not an issue. + + \section2 vxworksfb + + Use the \c fb plugin parameter to specify the framebuffer device to use. + +*/ diff --git a/doc/src/qmlapp/deployment.qdoc b/doc/src/qmlapp/deployment.qdoc index df2bb22c00ebf54ddea2902529acaad62e907901..ee5def6c396a209407e85bdce8de52743b674d85 100644 --- a/doc/src/qmlapp/deployment.qdoc +++ b/doc/src/qmlapp/deployment.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -46,13 +46,13 @@ a C++ application to load the QML runtime. \l{Qt Creator Manual}{Qt Creator} deploys and packages QML applications to various platforms. For mobile devices, Qt Creator can directly bundle -applications to the respective platform package formats such as APK and BAR. +applications to the respective platform package formats such as APK. For more information, visit: \list \li \l{Deploying Qt Applications} \li \l{Qt Creator: Running on Multiple Platforms}{Running on Multiple Platforms} -\li \l{Qt Creator: Deploying to Mobile Devices}{Deploying to Mobile Devices} +\li \l{Qt Creator: Deploying to Devices}{Deploying to Devices} \endlist When running applications on the target platform, the application needs to diff --git a/doc/src/snippets/widgets-tutorial/notepad/copy.png b/doc/src/snippets/widgets-tutorial/notepad/copy.png new file mode 100644 index 0000000000000000000000000000000000000000..cb3442c04c82253299c2489c452b67f5d07712a7 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/copy.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/create.png b/doc/src/snippets/widgets-tutorial/notepad/create.png new file mode 100644 index 0000000000000000000000000000000000000000..fdfd4b438ac3ff20c096a3b4aaea24f29dce30b7 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/create.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/cut.png b/doc/src/snippets/widgets-tutorial/notepad/cut.png new file mode 100644 index 0000000000000000000000000000000000000000..74b15301ff15ff77128513154b332d3c67ef8a71 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/cut.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/edit_redo.png b/doc/src/snippets/widgets-tutorial/notepad/edit_redo.png new file mode 100644 index 0000000000000000000000000000000000000000..8a7725463cc4ee7c09768b6be1ae6c00f722f323 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/edit_redo.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/edit_undo.png b/doc/src/snippets/widgets-tutorial/notepad/edit_undo.png new file mode 100644 index 0000000000000000000000000000000000000000..852f5e3b298044a8625d5bae41f2e327f3144eb5 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/edit_undo.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/exit.png b/doc/src/snippets/widgets-tutorial/notepad/exit.png new file mode 100644 index 0000000000000000000000000000000000000000..677d4deef202a908c6eccdea63236c400ae3ca53 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/exit.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/font.png b/doc/src/snippets/widgets-tutorial/notepad/font.png new file mode 100644 index 0000000000000000000000000000000000000000..925e501c03d6880950fc52a3bd047740561469e8 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/font.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/info.png b/doc/src/snippets/widgets-tutorial/notepad/info.png new file mode 100644 index 0000000000000000000000000000000000000000..9731212c4fb936a69b9cfe5cb791d4d6f29e35df Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/info.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/main.cpp b/doc/src/snippets/widgets-tutorial/notepad/main.cpp index 81c8c20d38e167e71de32e8399e04e528a3d3195..5a76f0255cc0711f7ffa922fffb8dd661cfd7aab 100644 --- a/doc/src/snippets/widgets-tutorial/notepad/main.cpp +++ b/doc/src/snippets/widgets-tutorial/notepad/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -59,17 +59,17 @@ int main(int argc, char *argv[]) { //! [2] //! [3] - QApplication a(argc, argv); + QApplication EditorApp(argc, argv); //! [3] //! [4] - Notepad w; + Notepad Editor; //! [4] //! [5] - w.show(); + Editor.show(); //! [5] //! [6] - return a.exec(); + return EditorApp.exec(); //! [6] } //! [all] diff --git a/doc/src/snippets/widgets-tutorial/notepad/new.png b/doc/src/snippets/widgets-tutorial/notepad/new.png new file mode 100644 index 0000000000000000000000000000000000000000..b24edc5d0cf21af413a16f285a9fa4ba2db3f73e Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/new.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/notepad.cpp b/doc/src/snippets/widgets-tutorial/notepad/notepad.cpp index c7ef71bcf09bdbd939529208eb5bc60a120d9163..f519bb66a7194a36eb01de326ef05f9cffef9b78 100644 --- a/doc/src/snippets/widgets-tutorial/notepad/notepad.cpp +++ b/doc/src/snippets/widgets-tutorial/notepad/notepad.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -52,66 +52,139 @@ #include "ui_notepad.h" //! [0] -#include <QFileDialog> #include <QFile> -#include <QMessageBox> +#include <QFileDialog> #include <QTextStream> +#include <QMessageBox> +#include <QprintDev> +#include <QPrintDialog> +#include <QFont> +#include <QFontDialog> //! [0] +//! [1] Notepad::Notepad(QWidget *parent) : QMainWindow(parent), ui(new Ui::Notepad) { ui->setupUi(this); + this->setCentralWidget(ui->textEdit); } +//! [1] Notepad::~Notepad() { delete ui; } -//! [1] -void Notepad::on_quitButton_clicked() +//! [2] +void Notepad::on_actionNew_triggered() { - QCoreApplication::quit(); + currentFile = ""; + ui->textEdit->setText(""); } -//! [1] - //! [2] + +//! [3] void Notepad::on_actionOpen_triggered() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QString(), - tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); - - if (!fileName.isEmpty()) { - QFile file(fileName); - if (!file.open(QIODevice::ReadOnly)) { - QMessageBox::critical(this, tr("Error"), tr("Could not open file")); - return; - } - QTextStream in(&file); - ui->textEdit->setText(in.readAll()); - file.close(); + QString fileName = QFileDialog::getOpenFileName(this, "Open the file"); + QFile file(fileName); + currentFile = fileName; + if (!file.open(QIODevice::ReadOnly | QFile::Text)) { + QMessageBox::warning(this,"..","File not opened."); + return; } + QTextStream in(&file); + QString text = in.readAll(); + ui->textEdit->setText(text); + file.close(); } -//! [2] - //! [3] + +//! [4] void Notepad::on_actionSave_triggered() { - QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), QString(), - tr("Text Files (*.txt);;C++ Files (*.cpp *.h)")); - - if (!fileName.isEmpty()) { - QFile file(fileName); - if (!file.open(QIODevice::WriteOnly)) { - // error message - } else { - QTextStream stream(&file); - stream << ui->textEdit->toPlainText(); - stream.flush(); - file.close(); + QFile file(currentFile); + if (!file.open(QIODevice::WriteOnly | QFile::Text)) { + QMessageBox::warning(this,"..","No file opened. Use Save As"); + return; + } + QTextStream out(&file); + QString text = ui->textEdit->toPlainText(); + out << text; + file.flush(); + file.close(); +} +//! [4] + +//! [5] +void Notepad::on_actionSave_as_triggered() +{ + QString fileName = QFileDialog::getSaveFileName(this, "Save as"); + QFile file(fileName); + currentFile = fileName; + if (!file.open(QFile::WriteOnly | QFile::Text)) { + QMessageBox::warning(this,"..","File not opened."); + return; + } + QTextStream out(&file); + QString text = ui->textEdit->toPlainText(); + out << text; + file.flush(); + file.close(); +} +//! [5] + +//! [6] +void Notepad::on_actionPrint_triggered() +{ + QprintDev printDev; + QPrintDialog dialog(&printDev, this); + if (dialog.exec() == QDialog::Rejected) { + return; } + ui->textEdit->print(&printDev); +} +//! [6] + +void Notepad::on_actionExit_triggered() +{ + QCoreApplication::quit(); +} + +void Notepad::on_actionCopy_triggered() +{ + ui->textEdit->copy(); +} + +void Notepad::on_actionCut_triggered() +{ + ui->textEdit->cut(); +} + +void Notepad::on_actionPaste_triggered() +{ + ui->textEdit->paste(); +} + +void Notepad::on_actionUndo_triggered() +{ + ui->textEdit->undo(); +} + +void Notepad::on_actionRedo_triggered() +{ + ui->textEdit->redo(); +} + +//! [7] +void Notepad::on_actionFont_triggered() +{ + bool fontSelected; + QFont font = QFontDialog::getFont(&fontSelected, this); + if (fontSelected) { + ui->textEdit->setFont(font); } } -//! [3] +//! [7] diff --git a/doc/src/snippets/widgets-tutorial/notepad/notepad.h b/doc/src/snippets/widgets-tutorial/notepad/notepad.h index ea8961afe39da2514a6c1bae9ff171f2e7a4bcf7..9bcdd725a9f2a51f5080d10689a3f253ebeef5ec 100644 --- a/doc/src/snippets/widgets-tutorial/notepad/notepad.h +++ b/doc/src/snippets/widgets-tutorial/notepad/notepad.h @@ -51,29 +51,62 @@ #ifndef NOTEPAD_H #define NOTEPAD_H +//! [all] +//! [1] #include <QMainWindow> +//! [1] +//! [2] namespace Ui { class Notepad; } +//! [2] +//! [3] class Notepad : public QMainWindow { Q_OBJECT +//! [3] +//! [4] public: explicit Notepad(QWidget *parent = 0); +//! [4] +//! [5] ~Notepad(); +//! [5] private slots: - void on_quitButton_clicked(); + void on_actionNew_triggered(); void on_actionOpen_triggered(); void on_actionSave_triggered(); + void on_actionSave_as_triggered(); + + void on_actionPrint_triggered(); + + void on_actionExit_triggered(); + + void on_actionCopy_triggered(); + + void on_actionCut_triggered(); + + void on_actionPaste_triggered(); + + void on_actionUndo_triggered(); + + void on_actionRedo_triggered(); + + void on_actionFont_triggered(); + +//! [6] private: Ui::Notepad *ui; + QString CurrentFile; +//! [6] }; +//! [all] #endif // NOTEPAD_H diff --git a/doc/src/snippets/widgets-tutorial/notepad/notepad.pro b/doc/src/snippets/widgets-tutorial/notepad/notepad.pro index 1aadcd306c1cdef9bf04e91229a9dd2f0bb3ba98..758c067eb661807e2130a7416cfcd0e766fb9414 100644 --- a/doc/src/snippets/widgets-tutorial/notepad/notepad.pro +++ b/doc/src/snippets/widgets-tutorial/notepad/notepad.pro @@ -1,10 +1,27 @@ -QT += core gui +#------------------------------------------------- +# +# Project created by QtCreator 2017-07-10T14:20:07 +# +#------------------------------------------------- + +QT += core gui printsupport greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = Notepad TEMPLATE = app +# The following define makes your compiler emit warnings if you use +# any feature of Qt which as been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + SOURCES += main.cpp\ notepad.cpp @@ -12,3 +29,6 @@ SOURCES += main.cpp\ HEADERS += notepad.h FORMS += notepad.ui + +RESOURCES += \ + notepad.qrc diff --git a/doc/src/snippets/widgets-tutorial/notepad/notepad.qrc b/doc/src/snippets/widgets-tutorial/notepad/notepad.qrc new file mode 100644 index 0000000000000000000000000000000000000000..3e04ad7e70829e9224545fa2de03f762b6ae91c5 --- /dev/null +++ b/doc/src/snippets/widgets-tutorial/notepad/notepad.qrc @@ -0,0 +1,19 @@ +<RCC> + <qresource prefix="/"> + <file>info.png</file> + <file>new.png</file> + <file>open.png</file> + <file>paste.png</file> + <file>pencil.png</file> + <file>print.png</file> + <file>save.png</file> + <file>save_as.png</file> + <file>exit.png</file> + <file>font.png</file> + <file>copy.png</file> + <file>create.png</file> + <file>cut.png</file> + <file>edit_redo.png</file> + <file>edit_undo.png</file> + </qresource> +</RCC> diff --git a/doc/src/snippets/widgets-tutorial/notepad/notepad.ui b/doc/src/snippets/widgets-tutorial/notepad/notepad.ui index 950cf718de1bf85bed03882edf05c2e4d01a7a79..59dfce3837664f70619926130b721b4d10262c5f 100644 --- a/doc/src/snippets/widgets-tutorial/notepad/notepad.ui +++ b/doc/src/snippets/widgets-tutorial/notepad/notepad.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>400</width> + <width>524</width> <height>300</height> </rect> </property> @@ -14,46 +14,47 @@ <string>Notepad</string> </property> <widget class="QWidget" name="centralWidget"> - <widget class="QWidget" name=""> - <property name="geometry"> - <rect> - <x>70</x> - <y>0</y> - <width>268</width> - <height>235</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTextEdit" name="textEdit"/> - </item> - <item> - <widget class="QPushButton" name="quitButton"> - <property name="text"> - <string>Quit</string> - </property> - </widget> - </item> - </layout> - </widget> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTextEdit" name="textEdit"/> + </item> + </layout> </widget> <widget class="QMenuBar" name="menuBar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>400</width> - <height>22</height> + <width>524</width> + <height>25</height> </rect> </property> <widget class="QMenu" name="menuFile"> <property name="title"> <string>File</string> </property> + <addaction name="actionNew"/> <addaction name="actionOpen"/> <addaction name="actionSave"/> + <addaction name="actionSave_as"/> + <addaction name="actionPrint"/> + <addaction name="separator"/> + <addaction name="actionExit"/> + </widget> + <widget class="QMenu" name="menuEdit"> + <property name="title"> + <string>Edit</string> + </property> + <addaction name="actionCopy"/> + <addaction name="actionCut"/> + <addaction name="actionPaste"/> + <addaction name="separator"/> + <addaction name="actionUndo"/> + <addaction name="actionRedo"/> + <addaction name="actionFont"/> </widget> <addaction name="menuFile"/> + <addaction name="menuEdit"/> </widget> <widget class="QToolBar" name="mainToolBar"> <attribute name="toolBarArea"> @@ -62,20 +63,134 @@ <attribute name="toolBarBreak"> <bool>false</bool> </attribute> + <addaction name="actionNew"/> + <addaction name="actionOpen"/> + <addaction name="actionSave"/> + <addaction name="actionSave_as"/> + <addaction name="actionPrint"/> + <addaction name="separator"/> + <addaction name="actionCopy"/> + <addaction name="actionCut"/> + <addaction name="actionPaste"/> + <addaction name="actionUndo"/> + <addaction name="actionRedo"/> + <addaction name="actionFont"/> + <addaction name="separator"/> + <addaction name="actionExit"/> </widget> <widget class="QStatusBar" name="statusBar"/> + <action name="actionNew"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/new.png</normaloff>:/new.png</iconset> + </property> + <property name="text"> + <string>New</string> + </property> + </action> <action name="actionOpen"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/open.png</normaloff>:/open.png</iconset> + </property> <property name="text"> <string>Open</string> </property> </action> <action name="actionSave"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/save.png</normaloff>:/save.png</iconset> + </property> <property name="text"> <string>Save</string> </property> </action> + <action name="actionSave_as"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/save_as.png</normaloff>:/save_as.png</iconset> + </property> + <property name="text"> + <string>Save as</string> + </property> + </action> + <action name="actionPrint"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/print.png</normaloff>:/print.png</iconset> + </property> + <property name="text"> + <string>Print</string> + </property> + </action> + <action name="actionExit"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/exit.png</normaloff>:/exit.png</iconset> + </property> + <property name="text"> + <string>Exit</string> + </property> + </action> + <action name="actionCopy"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/copy.png</normaloff>:/copy.png</iconset> + </property> + <property name="text"> + <string>Copy</string> + </property> + </action> + <action name="actionCut"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/cut.png</normaloff>:/cut.png</iconset> + </property> + <property name="text"> + <string>Cut</string> + </property> + </action> + <action name="actionPaste"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/paste.png</normaloff>:/paste.png</iconset> + </property> + <property name="text"> + <string>Paste</string> + </property> + </action> + <action name="actionUndo"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/edit_undo.png</normaloff>:/edit_undo.png</iconset> + </property> + <property name="text"> + <string>Undo</string> + </property> + </action> + <action name="actionRedo"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/edit_redo.png</normaloff>:/edit_redo.png</iconset> + </property> + <property name="text"> + <string>Redo</string> + </property> + </action> + <action name="actionFont"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/font.png</normaloff>:/font.png</iconset> + </property> + <property name="text"> + <string>Font</string> + </property> + </action> </widget> <layoutdefault spacing="6" margin="11"/> - <resources/> + <resources> + <include location="notepad.qrc"/> + </resources> <connections/> </ui> diff --git a/doc/src/snippets/widgets-tutorial/notepad/open.png b/doc/src/snippets/widgets-tutorial/notepad/open.png new file mode 100644 index 0000000000000000000000000000000000000000..7b052edf5a50530c220aef7fc6bac166dbd8a535 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/open.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/paste.png b/doc/src/snippets/widgets-tutorial/notepad/paste.png new file mode 100644 index 0000000000000000000000000000000000000000..c50dbd95b2bea80c21856dba62c7ee89330585ee Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/paste.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/pencil.png b/doc/src/snippets/widgets-tutorial/notepad/pencil.png new file mode 100644 index 0000000000000000000000000000000000000000..a9c5e5482ab997fb17e9d12632f9cd42cbf6c746 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/pencil.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/print.png b/doc/src/snippets/widgets-tutorial/notepad/print.png new file mode 100644 index 0000000000000000000000000000000000000000..0cd3f28bd82fa99440183e6c765346e9f15d11a4 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/print.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/save.png b/doc/src/snippets/widgets-tutorial/notepad/save.png new file mode 100644 index 0000000000000000000000000000000000000000..e65a29d5f1735d95d5e96fce818e251fbbc88ee1 Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/save.png differ diff --git a/doc/src/snippets/widgets-tutorial/notepad/save_as.png b/doc/src/snippets/widgets-tutorial/notepad/save_as.png new file mode 100644 index 0000000000000000000000000000000000000000..604057432233c9e8330c9f97cdf3a369bccde65a Binary files /dev/null and b/doc/src/snippets/widgets-tutorial/notepad/save_as.png differ diff --git a/doc/src/whatsnew/whatsnew53.qdoc b/doc/src/whatsnew/whatsnew53.qdoc index 16883697190eb309e04d3f3489585e90b11cf0b2..90f56c2ec0a3b38bf5e3f5e9ef5dc04108158596 100644 --- a/doc/src/whatsnew/whatsnew53.qdoc +++ b/doc/src/whatsnew/whatsnew53.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -170,10 +170,6 @@ To enable the plugin, go to \gui Help > \gui{About Plugins} and enable \gui WinRT in \gui{Device Support}. - For more information, visit the - \l{Qt Creator: Connecting Windows Runtime Devices}{Connecting Windows Runtime Devices} - page. - \section2 Editors \list \li Better support of multiple editors and windows.