Skip to content

Commit dc9bbbb

Browse files
sgaistASpoerl
authored andcommitted
doc: refactor C++ usage
The documentation mentions both a namespace that has been removed and the use of the module include which should be avoided in user code. This patch removes both, and adds CMake usage for the module. Pick-to: 6.9 6.8 Change-Id: I378fbcaffa3edc5bdb94cdb7e05c9876b2418931 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
1 parent 028f64f commit dc9bbbb

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

src/charts/doc/snippets/doc_src_qtcharts.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
// Copyright (C) 2016 The Qt Company Ltd.
22
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
33

4-
//! [0]
5-
#include <QtCharts>
6-
7-
using namespace QtCharts;
8-
//! [0]
9-
104
//! [1]
115
qmake CONFIG+=static
126
make

src/charts/doc/snippets/doc_src_qtcharts.pro

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (C) 2025 Samuel Gaist <samuel.gaist@idiap.ch>
2+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3+
4+
//! [cmakebuild]
5+
\code
6+
find_package(Qt6 COMPONENTS Charts REQUIRED)
7+
target_link_libraries(mytarget PRIVATE Qt6::Charts)
8+
\endcode
9+
//! [cmakebuild]
10+
11+
//! [qmakebuild]
12+
\code
13+
QT += charts
14+
\endcode
15+
//! [qmakebuild]

src/charts/doc/src/qtcharts.qdoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
\include deprecation-phase.qdocinc
1616

17-
If you intend to use Qt Charts C++ classes in your application, use the
18-
following include and using directives:
19-
20-
\snippet doc_src_qtcharts.cpp 0
17+
Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies.
18+
Several build tools have dedicated support for this, including CMake and qmake.
2119

2220
\if !defined(qtforpython)
2321
\note Projects created with Qt Creator's Qt Quick Application
@@ -26,9 +24,13 @@
2624
QApplication as the module depends on Qt's \l{Graphics View Framework}
2725
for rendering.
2826

29-
To link against the Qt Charts module, add this line to your \c qmake project file:
27+
To use the module with CMake, use the \c{find_package()} command to locate
28+
the needed module components in the \c{Qt6} package:
29+
\include qtcharts-module-use.qdocinc cmakebuild
3030

31-
\snippet doc_src_qtcharts.pro 0
31+
To use the module for building with qmake, add the module as a value of the
32+
\c QT variable in the project's .pro file:
33+
\include qtcharts-module-use.qdocinc qmakebuild
3234
\endif
3335

3436
Each chart type is represented by the QAbstractSeries derived class. To create charts, the users have to use an instance of the related

0 commit comments

Comments
 (0)