summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-02-17 11:35:03 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-02-17 11:35:03 +0100
commitc94ae31c363aaee26757eb5b0e36857bb665c88e (patch)
tree411e70087380fbc870340dea1a1f17c35558867a
parent3f440b287a6b40f539eb91acb16a3d972829130d (diff)
parent19245e88bae96a8f3757c8db8e5f3104eae12db9 (diff)
Merge remote-tracking branch 'origin/stable' into dev
-rw-r--r--doc/src/external-resources.qdoc2
-rw-r--r--doc/src/getting-started/gettingstartedqt.qdoc123
-rw-r--r--doc/src/howtos/appicon.qdoc14
-rw-r--r--doc/src/snippets/code/doc_src_appicon.qdoc7
-rw-r--r--doc/src/snippets/gs/notepad1.cpp13
-rw-r--r--doc/src/snippets/gs/notepad1.h12
-rw-r--r--doc/src/snippets/gs/notepad2.h2
-rw-r--r--doc/src/snippets/widgets-tutorial/notepad/main.cpp12
8 files changed, 149 insertions, 36 deletions
diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc
index 4d0a382c0..5a4e100a8 100644
--- a/doc/src/external-resources.qdoc
+++ b/doc/src/external-resources.qdoc
@@ -110,7 +110,7 @@
*/
/*!
- \externalpage http://qt.digia.com/Try-Qt-Now/
+ \externalpage http://qt.digia.com/Try-Buy/
\title Try Qt Enterprise
*/
/*!
diff --git a/doc/src/getting-started/gettingstartedqt.qdoc b/doc/src/getting-started/gettingstartedqt.qdoc
index 67f957a10..59e68fd1e 100644
--- a/doc/src/getting-started/gettingstartedqt.qdoc
+++ b/doc/src/getting-started/gettingstartedqt.qdoc
@@ -97,7 +97,7 @@
\li \l{Qt Creator Manual}{Qt Creator}
\row
\li Creating other kind of applications with Qt Creator
- \li \l{Tutorials for Creator}{Qt Creator Tutorials}
+ \li \l{Qt Creator: Tutorials}{Qt Creator Tutorials}
\endtable
@@ -107,38 +107,52 @@
\snippet snippets/widgets-tutorial/notepad/main.cpp all
- Let us go through the code line by line. On the first two lines, we include
+ Let us 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.
- Line 4 defines the main function that is the entry point for all C and C++
- based applications.
+ \snippet snippets/widgets-tutorial/notepad/main.cpp 1
- Line 6 creates a QApplication object. This object manages
+ The following line defines the main function that is the entry point for
+ all C and C++ based applications:
+
+ \snippet snippets/widgets-tutorial/notepad/main.cpp 2
+
+ 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.)
- Line 7 creates the Notepad object. This is the object for which the wizard
+ \snippet snippets/widgets-tutorial/notepad/main.cpp 3
+
+ The following line creates the Notepad object. This is the object for
+ which the wizard
created the class and the UI file. The user interface contains visual
elements that are called \c widgets in Qt. Examples of widgets are text
edits, scroll bars, labels, and radio buttons. A widget can also be a
container for other widgets; a dialog or a main application window, for
example.
- Line 8 shows the Notepad widget on the screen in its own window.
+ \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.
- Line 10 makes the QApplication enter its event loop. When a Qt
+ \snippet snippets/widgets-tutorial/notepad/main.cpp 5
+
+ The following line makes the QApplication enter its event loop. When a Qt
application is running, events are generated and sent to the
widgets of the application. Examples of events are mouse presses
and key strokes.
+ \snippet snippets/widgets-tutorial/notepad/main.cpp 6
+
\b{Learn More}
\table
@@ -206,18 +220,42 @@
\printuntil QMenuBar
\dots
- Line 1 contains the XML declaration, which specifies the XML version and
- character encoding used in the document.
+ The following line contains the XML declaration, which specifies the XML
+ version and character encoding used in the document:
+
+ \code
+ <?xml version="1.0" encoding="UTF-8"?>
+ \endcode
- Line 2 creates an \c ui element that defines a Notepad widget.
+ The rest of the file specifies an \c ui element that defines a Notepad
+ widget:
- Line 26 creates a QVBoxLayout widget that contains a QTextEdit
+ \code
+ <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.
@@ -229,34 +267,48 @@
\snippet snippets/gs/notepad1.h all
- Line 4 includes QMainWindow that provides a main application window.
+ The following line includes QMainWindow that provides a main application
+ window:
+
+ \snippet snippets/gs/notepad1.h 1
- Line 6 declares the Notepad class in the Ui namespace, which is the
+ The following lines declare the Notepad class in the Ui namespace, which is the
standard namespace for the UI classes generated from .ui files by the
- \c uic tool.
+ \c uic tool:
- Line 10 contains the \c Q_OBJECT macro. It must come first in the class
+ \snippet snippets/gs/notepad1.h 2
+
+ The class declaration contains the \c Q_OBJECT macro. It must come first in the class
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
parameter types and invoke it.
- Line 15 declares a constructor that has a default argument called \c parent.
+ \snippet snippets/gs/notepad1.h 3
+
+ The following lines declare a constructor that has a default argument
+ called \c parent.
The value 0 indicates that the widget has no parent (it is a top-level
widget).
- Line 16 declares a virtual destructor to free the resources that were
+ \snippet snippets/gs/notepad1.h 4
+
+ The following line declares a virtual destructor to free the resources that were
acquired by the object during its life-cycle. According to the C++
naming convention, destructors have the same name as the class they are
associated with, prefixed with a tilde (~). In QObject, destructors are
virtual to ensure that the destructors of derived classes are invoked
properly when an object is deleted through a pointer-to-base-class.
- Line 19 declares a member variable which is a pointer to the Notepad UI
+ \snippet snippets/gs/notepad1.h 5
+
+ The following lines declare a member variable which is a pointer to the Notepad UI
class. A member variable is associated with a specific class, and accessible
for all its methods.
+ \snippet snippets/gs/notepad1.h 6
+
\section2 Notepad Source File
The source file that the wizard generated for the Notepad class looks as
@@ -264,19 +316,32 @@
\snippet snippets/gs/notepad1.cpp all
- The first two lines include the Notepad class header file that was generated
- by the wizard and the UI header file that was generated by the \c uic tool.
+ The following lines include the Notepad class header file that was generated
+ by the wizard and the UI header file that was generated by the \c uic tool:
- Line 4 defines the \c {Notepad} constructor and sets up the UI file.
+ \snippet snippets/gs/notepad1.cpp 0
- Line 5 calls the QMainWindow constructor, which is the base class for the
- Notepad class.
+ The following line defines the \c {Notepad} constructor:
- Line 6 creates the UI class instance and assigns it to the \c ui member.
+ \snippet snippets/gs/notepad1.cpp 1
- Line 8 sets up the UI.
+ The following line calls the QMainWindow constructor, which is the base
+ class for the Notepad class:
- Line 11 destructs the \c ui.
+ \snippet snippets/gs/notepad1.cpp 2
+
+ The following line creates the UI class instance and assigns it to the
+ \c ui member:
+
+ \snippet snippets/gs/notepad1.cpp 3
+
+ The following line sets up the UI:
+
+ \snippet snippets/gs/notepad1.cpp 4
+
+ In the destructor, we delete the \c ui:
+
+ \snippet snippets/gs/notepad1.cpp 5
\section2 Project File
@@ -359,7 +424,7 @@
\snippet snippets/gs/notepad2.h all
- Line 14 uses Qt's signals and slots mechanism to make the
+ 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
@@ -367,6 +432,8 @@
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:
\snippet snippets/gs/notepad2.cpp all
diff --git a/doc/src/howtos/appicon.qdoc b/doc/src/howtos/appicon.qdoc
index 1d0be0dc2..9a57b92c8 100644
--- a/doc/src/howtos/appicon.qdoc
+++ b/doc/src/howtos/appicon.qdoc
@@ -161,12 +161,16 @@
\section2 K Desktop Environment (KDE)
Application icons can be installed for use by all users, or on a per-user basis.
- A user currently logged into their KDE desktop can discover these locations
- by using \l{http://developer.kde.org/documentation/other/kde-config.html}{kde-config},
- for example, by typing the following in a terminal window:
+ A user currently logged into their KDE 4 desktop can discover these locations
+ by using kde4-config, for example, by typing the following in a terminal window:
\snippet snippets/code/doc_src_appicon.qdoc 3
+ Applications using Qt 5 and KDE Frameworks 5 will find their icons in the list
+ returned by this command:
+
+ \snippet snippets/code/doc_src_appicon.qdoc 5
+
Typically, the list of colon-separated paths printed to stdout includes the
user-specific icon path and the system-wide path. Beneath these
directories, it should be possible to locate and install icons according
@@ -175,11 +179,11 @@
If you are developing exclusively for KDE, you may wish to take
advantage of the \link
- http://developer.kde.org/documentation/other/makefile_am_howto.html
+ http://techbase.kde.org/Development/CMake/Addons_for_KDE
KDE build system\endlink to configure your application. This ensures
that your icons are installed in the appropriate locations for KDE.
- The KDE developer website is at \l{http://developer.kde.org/}.
+ The KDE developer website is at \l{http://techbase.kde.org/}.
\section2 GNOME
diff --git a/doc/src/snippets/code/doc_src_appicon.qdoc b/doc/src/snippets/code/doc_src_appicon.qdoc
index f75c0617a..d15863e69 100644
--- a/doc/src/snippets/code/doc_src_appicon.qdoc
+++ b/doc/src/snippets/code/doc_src_appicon.qdoc
@@ -44,10 +44,13 @@ IDI_ICON1 ICON DISCARDABLE "myappico.ico"
//! [3]
-kde-config --path icon
+kde4-config --path icon
//! [3]
-
//! [4]
gnome-config --datadir
//! [4]
+
+//! [5]
+qtpaths --locate-dirs GenericDataLocation icons
+//! [5]
diff --git a/doc/src/snippets/gs/notepad1.cpp b/doc/src/snippets/gs/notepad1.cpp
index b4ff493b5..4c27aa854 100644
--- a/doc/src/snippets/gs/notepad1.cpp
+++ b/doc/src/snippets/gs/notepad1.cpp
@@ -39,18 +39,31 @@
****************************************************************************/
//! [all]
+//! [0]
#include "notepad.h"
#include "ui_notepad.h"
+//! [0]
+//! [1]
Notepad::Notepad(QWidget *parent) :
+//! [1]
+//! [2]
QMainWindow(parent),
+//! [2]
+//! [3]
ui(new Ui::Notepad)
+//! [3]
{
+
+//! [4]
ui->setupUi(this);
+//! [4]
}
+//! [5]
Notepad::~Notepad()
{
delete ui;
}
+//! [5]
//! [all]
diff --git a/doc/src/snippets/gs/notepad1.h b/doc/src/snippets/gs/notepad1.h
index df043dd46..50c61a4f3 100644
--- a/doc/src/snippets/gs/notepad1.h
+++ b/doc/src/snippets/gs/notepad1.h
@@ -42,22 +42,34 @@
#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]
+//! [6]
private:
Ui::Notepad *ui;
+//! [6]
};
//! [all]
diff --git a/doc/src/snippets/gs/notepad2.h b/doc/src/snippets/gs/notepad2.h
index bac6d43fc..a7e86c2f9 100644
--- a/doc/src/snippets/gs/notepad2.h
+++ b/doc/src/snippets/gs/notepad2.h
@@ -51,8 +51,10 @@ public:
explicit Notepad(QWidget *parent = 0);
~Notepad();
+//! [1]
private slots:
void on_quitButton_clicked();
+//! [1]
private:
Ui::Notepad *ui;
diff --git a/doc/src/snippets/widgets-tutorial/notepad/main.cpp b/doc/src/snippets/widgets-tutorial/notepad/main.cpp
index 7fb83194c..2393eb43f 100644
--- a/doc/src/snippets/widgets-tutorial/notepad/main.cpp
+++ b/doc/src/snippets/widgets-tutorial/notepad/main.cpp
@@ -39,15 +39,27 @@
****************************************************************************/
//! [all]
+//! [1]
#include "notepad.h"
#include <QApplication>
+//! [1]
+//! [2]
int main(int argc, char *argv[])
{
+//! [2]
+//! [3]
QApplication a(argc, argv);
+//! [3]
+//! [4]
Notepad w;
+//! [4]
+//! [5]
w.show();
+//! [5]
+//! [6]
return a.exec();
+//! [6]
}
//! [all]