QCustomPlot can be compiled with the special Qt flags QT_NO_CAST_FROM_ASCII
and QT_NO_CAST_TO_ASCII
out of the box. All strings used in the library are wrapped in QLatin1String to avoid casts from string/char literals. So if your project requires the added cast safety from these Qt flags, you can use QCustomPlot without any changes necessary.
QCustomPlot is a library based on and written in Qt. This means it uses Qt keywords such as foreach
, signal
, slot
and emit
for improved legibility.
However, some projects wish to disable these Qt specific language extensions by using the define flag QT_NO_KEYWORDS
. To compile QCustomPlot with that flag set, it is necessary to replace all occurances of Qt keywords. This is easily done with QCustomPlot code, by using the following regular expression replacements:
Search pattern | Replace with |
(^|[^\a_])emit\s | \1Q_EMIT —note the trailing space |
^( *)signals: | \1Q_SIGNALS: |
(^|[^\a_])foreach( *)\( | \1Q_FOREACH\2( |
QCustomPlot code is written with these replacements in mind. They always work and catch all occurances of used Qt keywords. Their functioning is also automatically tested upon every release.
The regular expressions can be applied in any IDE/Editor that supports them, including QtCreator itself. Below is a python script that is used to test the functioning of the regular expressions. It takes the names of the files to process (e.g. qcustomplot.cpp qcustomplot.h) from the command line and performs the replacement on them.