summaryrefslogtreecommitdiffstats
path: root/examples/pdfwidgets/pdfviewer/doc/src/pdfviewer.qdoc
blob: 9c7b3deeddb8047201bd100b019b92eb01113eb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \example pdfviewer
    \ingroup qtpdf-examples

    \title PDF Viewer Example
    \brief Renders PDF documents.

    \image pdfviewer.png

    \e {PDF Viewer} demonstrates how to use the \l QPdfDocument class to render
    PDF documents and the \l QPdfPageNavigation class to navigate them.

    Qt Creator and the integrated Qt Designer were used to create the example
    UI and to connect it to the code. This affects the code, which might be
    somewhat different to what you would typically write by hand.
    For more information about using Qt Designer, see \l{Qt Designer Manual}
    and \l{Qt Creator: Creating a Qt Widget Based Application}.

    \include examples-run.qdocinc

    \section1 Creating the Main Window

    The MainWindow class inherits the QMainWindow class:

    \quotefromfile pdfviewer/mainwindow.h
    \skipto public QMainWindow
    \printuntil ~MainWindow()

    The class declares public and private slots that match the actions of the
    selectors:

    \printuntil on_actionContinuous_triggered()

    The actual layout of the main window is specified in a \c{.ui} file. The
    widgets and actions are available at runtime in the \c ui member variable.

    \printuntil Ui::

    The \c m_zoomSelector variable holds the zoom selector and the
    \c m_pageSelector holds the page selector. The \c m_document
    variable is an instance of the QPdfDocument class that contains
    the PDF document.

    \printuntil }

    The actual setup of the different objects is done in the MainWindow
    constructor:

    \quotefromfile pdfviewer/mainwindow.cpp
    \skipto MainWindow::
    \printuntil {

    The constructor first calls \c setupUi() to construct the zoom and page
    selectors according to the UI file. We set the maximum width of the
    selectors.

    \printuntil addWidget(m_pageSelector)

    We use the \l QPdfPageNavigation class to handle the navigation through a
    PDF document:

    \printuntil setPageNavigation

    We connect the \c zoomModeChanged and \c zoomFactor changed signals of the
    PDF view to the functions that reset the zoom selector:

    \printuntil reset()

    We then load the PDF document to the viewer:

    \dots
    \skipto pdfView
    \printuntil ;

    Finally, we connect the \c zoomFactorChanged signal to the function that
    sets the value of the zoom selector:

    \printuntil }

    \section1 Files and Attributions
*/