From 0a5fa424706b40322b42edf6f288af440dc5b67d Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Fri, 22 Apr 2022 13:27:31 +0200 Subject: [PATCH] more required changes for Qt6 compatibility --- .../jkqtplotter_common_compilersettings.cmake | 3 - cmake/jkqtplotter_common_qtsettings.cmake | 14 +- cmake/jkqtplotter_deployqt.cmake | 29 ++- examples/advplotstyling/advplotstyling.cpp | 3 +- examples/barchart/barchart.cpp | 3 +- examples/boxplot/boxplot.cpp | 3 +- examples/contourplot/contourplot.cpp | 2 +- examples/datastore/datastore.cpp | 3 +- .../datastore_groupedstat.cpp | 3 +- .../datastore_iterators.cpp | 3 +- .../datastore_regression.cpp | 3 +- .../datastore_statistics.cpp | 3 +- .../datastore_statistics_2d.cpp | 3 +- examples/dateaxes/dateaxes.cpp | 3 +- .../test_distributionplot.cpp | 3 +- examples/errorbarstyles/errorbarstyles.cpp | 3 +- examples/evalcurve/evalcurve.cpp | 3 +- examples/filledgraphs/filledgraphs.cpp | 3 +- examples/functionplot/functionplot.cpp | 3 +- examples/geo_arrows/geo_arrows.cpp | 3 +- examples/geo_simple/geo_simple.cpp | 3 +- examples/geometric/geometric.cpp | 3 +- examples/imageplot/imageplot.cpp | 3 +- .../imageplot_modifier/imageplot_modifier.cpp | 3 +- .../imageplot_nodatastore.cpp | 3 +- .../imageplot_userpal/imageplot_userpal.cpp | 3 +- examples/impulsesplot/impulsesplot.cpp | 3 +- .../jkqtmathtext_simpletest.cpp | 2 +- .../jkqtmathtext_test/jkqtmathtext_test.cpp | 3 +- examples/jkqtplot_test/jkqtplot_test.cpp | 3 +- examples/logaxes/logaxes.cpp | 3 +- examples/mandelbrot/mandelbrot.cpp | 3 +- examples/multiplot/test_multiplot.cpp | 3 +- examples/parametriccurve/parametriccurve.cpp | 3 +- .../paramscatterplot/paramscatterplot.cpp | 3 +- .../paramscatterplot_image.cpp | 3 +- .../parsedfunctionplot/parsedfunctionplot.cpp | 3 +- examples/rgbimageplot/rgbimageplot.cpp | 3 +- examples/rgbimageplot_qt/rgbimageplot_qt.cpp | 3 +- examples/simpletest/simpletest.cpp | 6 +- examples/speed/speed.cpp | 3 +- examples/stackedbars/stackedbars.cpp | 3 +- examples/stepplots/stepplots.cpp | 3 +- examples/styledboxplot/test_styledboxplot.cpp | 3 +- examples/styling/test_styling_main.cpp | 3 +- .../symbols_and_errors/symbols_and_errors.cpp | 3 +- .../symbols_and_styles/symbols_and_styles.cpp | 3 +- examples/ui/ui.cpp | 3 +- .../test_user_interaction_main.cpp | 3 +- examples/violinplot/violinplot.cpp | 3 +- lib/CMakeLists.txt | 5 +- lib/jkqtcommon/CMakeLists.txt | 24 ++- lib/jkqtcommon/LibTarget.cmake.in | 3 +- lib/jkqtcommon/jkqttools.cpp | 35 ++-- lib/jkqtcommon/jkqttools.h | 6 + lib/jkqtfastplotter/CMakeLists.txt | 29 ++- lib/jkqtfastplotter/LibTarget.cmake.in | 6 +- lib/jkqtmathtext/CMakeLists.txt | 24 ++- lib/jkqtmathtext/LibTarget.cmake.in | 3 +- lib/jkqtmathtext/jkqtmathtext.h | 8 +- lib/jkqtplotter/CMakeLists.txt | 24 ++- lib/jkqtplotter/LibTarget.cmake.in | 3 +- lib/jkqtplotter/graphs/jkqtpcontour.cpp | 3 +- .../gui/jkqtpenhancedtableview.cpp | 91 ++++++++- lib/jkqtplotter/jkqtpbaseplotter.cpp | 191 ++++++++++-------- lib/jkqtplotter/jkqtpbaseplotter.h | 6 +- lib/jkqtplotter/jkqtpdatastorage.cpp | 2 +- lib/jkqtplotter/jkqtpdatastorage.h | 3 +- lib/jkqtplotter/jkqtplotter.cpp | 20 +- lib/jkqtplotter/jkqtplotter.h | 21 +- 70 files changed, 471 insertions(+), 224 deletions(-) diff --git a/cmake/jkqtplotter_common_compilersettings.cmake b/cmake/jkqtplotter_common_compilersettings.cmake index 14dac1bec9..627cbff808 100644 --- a/cmake/jkqtplotter_common_compilersettings.cmake +++ b/cmake/jkqtplotter_common_compilersettings.cmake @@ -1,8 +1,5 @@ cmake_minimum_required(VERSION 3.1) -# configure compiler -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED on) if(NOT APPLE) set(CMAKE_INSTALL_RPATH $ORIGIN) diff --git a/cmake/jkqtplotter_common_qtsettings.cmake b/cmake/jkqtplotter_common_qtsettings.cmake index e46832d562..60852916e0 100644 --- a/cmake/jkqtplotter_common_qtsettings.cmake +++ b/cmake/jkqtplotter_common_qtsettings.cmake @@ -6,7 +6,15 @@ set(CMAKE_AUTOUIC ON) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) -if(${QT_VERSION_MAJOR}>=6) - find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGLWidgets REQUIRED) - +if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "6") + find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS OpenGLWidgets) +endif() + +# configure compiler +if(${QT_VERSION_MAJOR} VERSION_LESS "6" ) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED on) +else() + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED on) endif() diff --git a/cmake/jkqtplotter_deployqt.cmake b/cmake/jkqtplotter_deployqt.cmake index 270e6e0072..ac1f937865 100644 --- a/cmake/jkqtplotter_deployqt.cmake +++ b/cmake/jkqtplotter_deployqt.cmake @@ -3,13 +3,26 @@ function(jkqtplotter_deployqt TARGET_NAME) if (WIN32) get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) - find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}") - - set(WINDEPLOYQTOPTION "--release") + find_program(WINDEPLOYQT_ENV_SETUP qtenv2.bat HINTS "${_qt_bin_dir}") if (CMAKE_BUILD_TYPE STREQUAL "Debug") - set(WINDEPLOYQTOPTION "--debug") + find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt.debug.bat HINTS "${_qt_bin_dir}") + else() + find_program(WINDEPLOYQT_EXECUTABLE NAMES windeployqt HINTS "${_qt_bin_dir}") + endif() + + + if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "6") + set(WINDEPLOYQTOPTION "") + set(WINDEPLOYQTPACKAGES "") + else() + set(WINDEPLOYQTOPTION "--release --compiler-runtime") + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(WINDEPLOYQTOPTION "--debug --compiler-runtime") + endif() + set(WINDEPLOYQTPACKAGES "-xml -printsupport -svg -opengl") endif() + # install system runtime lib include( InstallRequiredSystemLibraries ) if( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ) @@ -18,13 +31,7 @@ function(jkqtplotter_deployqt TARGET_NAME) get_filename_component(CMAKE_CXX_COMPILER_BINPATH ${CMAKE_CXX_COMPILER} DIRECTORY ) add_custom_command(TARGET ${TARGET_NAME} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E - env PATH="${CMAKE_CXX_COMPILER_BINPATH}\;${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}" - --compiler-runtime - -xml - -printsupport - ${WINDEPLOYQTOPTION} - \"$\" + COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" ${WINDEPLOYQTOPTION} ${WINDEPLOYQTPACKAGES} \"$\" COMMENT "Running windeployqt ... " ) endif(WIN32) diff --git a/examples/advplotstyling/advplotstyling.cpp b/examples/advplotstyling/advplotstyling.cpp index 410fa5b5a0..a5f7ef87cf 100644 --- a/examples/advplotstyling/advplotstyling.cpp +++ b/examples/advplotstyling/advplotstyling.cpp @@ -14,7 +14,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/barchart/barchart.cpp b/examples/barchart/barchart.cpp index 79d9698ce6..8445cd7b89 100644 --- a/examples/barchart/barchart.cpp +++ b/examples/barchart/barchart.cpp @@ -103,7 +103,8 @@ void doExample() int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/boxplot/boxplot.cpp b/examples/boxplot/boxplot.cpp index bc49a8d138..28088f9ac2 100644 --- a/examples/boxplot/boxplot.cpp +++ b/examples/boxplot/boxplot.cpp @@ -12,7 +12,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/contourplot/contourplot.cpp b/examples/contourplot/contourplot.cpp index 0334927733..38bee9f170 100644 --- a/examples/contourplot/contourplot.cpp +++ b/examples/contourplot/contourplot.cpp @@ -20,7 +20,7 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/datastore/datastore.cpp b/examples/datastore/datastore.cpp index 8397187b21..b85c019134 100644 --- a/examples/datastore/datastore.cpp +++ b/examples/datastore/datastore.cpp @@ -13,7 +13,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/datastore_groupedstat/datastore_groupedstat.cpp b/examples/datastore_groupedstat/datastore_groupedstat.cpp index dfc5ff73b8..b4b459395e 100644 --- a/examples/datastore_groupedstat/datastore_groupedstat.cpp +++ b/examples/datastore_groupedstat/datastore_groupedstat.cpp @@ -19,7 +19,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/datastore_iterators/datastore_iterators.cpp b/examples/datastore_iterators/datastore_iterators.cpp index 9df46f70e2..8224555e7b 100644 --- a/examples/datastore_iterators/datastore_iterators.cpp +++ b/examples/datastore_iterators/datastore_iterators.cpp @@ -13,7 +13,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/datastore_regression/datastore_regression.cpp b/examples/datastore_regression/datastore_regression.cpp index 3e3d07c369..7ceeafd34d 100644 --- a/examples/datastore_regression/datastore_regression.cpp +++ b/examples/datastore_regression/datastore_regression.cpp @@ -19,7 +19,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/datastore_statistics/datastore_statistics.cpp b/examples/datastore_statistics/datastore_statistics.cpp index 3d7e6dd8bc..975776f34a 100644 --- a/examples/datastore_statistics/datastore_statistics.cpp +++ b/examples/datastore_statistics/datastore_statistics.cpp @@ -19,7 +19,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/datastore_statistics_2d/datastore_statistics_2d.cpp b/examples/datastore_statistics_2d/datastore_statistics_2d.cpp index e2a80c75cf..6f55435fce 100644 --- a/examples/datastore_statistics_2d/datastore_statistics_2d.cpp +++ b/examples/datastore_statistics_2d/datastore_statistics_2d.cpp @@ -19,7 +19,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/dateaxes/dateaxes.cpp b/examples/dateaxes/dateaxes.cpp index 8509af9c6a..af0597c996 100644 --- a/examples/dateaxes/dateaxes.cpp +++ b/examples/dateaxes/dateaxes.cpp @@ -169,7 +169,8 @@ void drawWithTimeAxis(JKQTPlotter& plot) { int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/distributionplot/test_distributionplot.cpp b/examples/distributionplot/test_distributionplot.cpp index e955830088..236e0be538 100644 --- a/examples/distributionplot/test_distributionplot.cpp +++ b/examples/distributionplot/test_distributionplot.cpp @@ -18,7 +18,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/errorbarstyles/errorbarstyles.cpp b/examples/errorbarstyles/errorbarstyles.cpp index 718dcbbe8a..387c71f375 100644 --- a/examples/errorbarstyles/errorbarstyles.cpp +++ b/examples/errorbarstyles/errorbarstyles.cpp @@ -13,7 +13,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/evalcurve/evalcurve.cpp b/examples/evalcurve/evalcurve.cpp index 2704d23461..62c3689b41 100644 --- a/examples/evalcurve/evalcurve.cpp +++ b/examples/evalcurve/evalcurve.cpp @@ -14,7 +14,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/filledgraphs/filledgraphs.cpp b/examples/filledgraphs/filledgraphs.cpp index 3664e484bc..8e9eddb7b2 100644 --- a/examples/filledgraphs/filledgraphs.cpp +++ b/examples/filledgraphs/filledgraphs.cpp @@ -11,7 +11,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/functionplot/functionplot.cpp b/examples/functionplot/functionplot.cpp index c1a5972f35..b8623a8b30 100644 --- a/examples/functionplot/functionplot.cpp +++ b/examples/functionplot/functionplot.cpp @@ -135,7 +135,8 @@ void drawExample(QApplication& app, const QString& name) { int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/geo_arrows/geo_arrows.cpp b/examples/geo_arrows/geo_arrows.cpp index 855991ed85..04173a9160 100644 --- a/examples/geo_arrows/geo_arrows.cpp +++ b/examples/geo_arrows/geo_arrows.cpp @@ -13,7 +13,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/geo_simple/geo_simple.cpp b/examples/geo_simple/geo_simple.cpp index 7b320de627..a03a027982 100644 --- a/examples/geo_simple/geo_simple.cpp +++ b/examples/geo_simple/geo_simple.cpp @@ -85,7 +85,8 @@ void drawEllExample(JKQTPlotter* plot, double x0, double y0, double wid, double int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/geometric/geometric.cpp b/examples/geometric/geometric.cpp index 8cc436ced4..dbe58ea5fd 100644 --- a/examples/geometric/geometric.cpp +++ b/examples/geometric/geometric.cpp @@ -13,7 +13,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/imageplot/imageplot.cpp b/examples/imageplot/imageplot.cpp index b2a161edbf..bf7c74a26e 100644 --- a/examples/imageplot/imageplot.cpp +++ b/examples/imageplot/imageplot.cpp @@ -13,7 +13,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/imageplot_modifier/imageplot_modifier.cpp b/examples/imageplot_modifier/imageplot_modifier.cpp index 8a0b046466..24089e7bf4 100644 --- a/examples/imageplot_modifier/imageplot_modifier.cpp +++ b/examples/imageplot_modifier/imageplot_modifier.cpp @@ -12,7 +12,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/imageplot_nodatastore/imageplot_nodatastore.cpp b/examples/imageplot_nodatastore/imageplot_nodatastore.cpp index a059204a42..c9f5c36782 100644 --- a/examples/imageplot_nodatastore/imageplot_nodatastore.cpp +++ b/examples/imageplot_nodatastore/imageplot_nodatastore.cpp @@ -12,7 +12,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/imageplot_userpal/imageplot_userpal.cpp b/examples/imageplot_userpal/imageplot_userpal.cpp index c95b7503cd..0350bcd692 100644 --- a/examples/imageplot_userpal/imageplot_userpal.cpp +++ b/examples/imageplot_userpal/imageplot_userpal.cpp @@ -18,7 +18,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/impulsesplot/impulsesplot.cpp b/examples/impulsesplot/impulsesplot.cpp index 40595d22f2..60c86ef990 100644 --- a/examples/impulsesplot/impulsesplot.cpp +++ b/examples/impulsesplot/impulsesplot.cpp @@ -14,7 +14,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/jkqtmathtext_simpletest/jkqtmathtext_simpletest.cpp b/examples/jkqtmathtext_simpletest/jkqtmathtext_simpletest.cpp index c4bde330aa..0dd14d056d 100644 --- a/examples/jkqtmathtext_simpletest/jkqtmathtext_simpletest.cpp +++ b/examples/jkqtmathtext_simpletest/jkqtmathtext_simpletest.cpp @@ -12,7 +12,7 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/jkqtmathtext_test/jkqtmathtext_test.cpp b/examples/jkqtmathtext_test/jkqtmathtext_test.cpp index a2032e8523..82455cbbd5 100644 --- a/examples/jkqtmathtext_test/jkqtmathtext_test.cpp +++ b/examples/jkqtmathtext_test/jkqtmathtext_test.cpp @@ -4,7 +4,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/jkqtplot_test/jkqtplot_test.cpp b/examples/jkqtplot_test/jkqtplot_test.cpp index 6301ad2c7a..cf04590070 100644 --- a/examples/jkqtplot_test/jkqtplot_test.cpp +++ b/examples/jkqtplot_test/jkqtplot_test.cpp @@ -6,7 +6,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/logaxes/logaxes.cpp b/examples/logaxes/logaxes.cpp index 22853f2029..3c6496737e 100644 --- a/examples/logaxes/logaxes.cpp +++ b/examples/logaxes/logaxes.cpp @@ -15,7 +15,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/mandelbrot/mandelbrot.cpp b/examples/mandelbrot/mandelbrot.cpp index ad0cf6b922..ed4e0b3f73 100644 --- a/examples/mandelbrot/mandelbrot.cpp +++ b/examples/mandelbrot/mandelbrot.cpp @@ -13,7 +13,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/multiplot/test_multiplot.cpp b/examples/multiplot/test_multiplot.cpp index 70561e3748..76cbe66854 100644 --- a/examples/multiplot/test_multiplot.cpp +++ b/examples/multiplot/test_multiplot.cpp @@ -16,7 +16,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/parametriccurve/parametriccurve.cpp b/examples/parametriccurve/parametriccurve.cpp index bfd1204a7a..07ac4f35b2 100644 --- a/examples/parametriccurve/parametriccurve.cpp +++ b/examples/parametriccurve/parametriccurve.cpp @@ -12,7 +12,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/paramscatterplot/paramscatterplot.cpp b/examples/paramscatterplot/paramscatterplot.cpp index a8ab58efe6..1ed1eca51b 100644 --- a/examples/paramscatterplot/paramscatterplot.cpp +++ b/examples/paramscatterplot/paramscatterplot.cpp @@ -12,7 +12,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/paramscatterplot_image/paramscatterplot_image.cpp b/examples/paramscatterplot_image/paramscatterplot_image.cpp index 836df15414..ee406f7a94 100644 --- a/examples/paramscatterplot_image/paramscatterplot_image.cpp +++ b/examples/paramscatterplot_image/paramscatterplot_image.cpp @@ -13,7 +13,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/parsedfunctionplot/parsedfunctionplot.cpp b/examples/parsedfunctionplot/parsedfunctionplot.cpp index 68a2284508..7d68b5b9e3 100644 --- a/examples/parsedfunctionplot/parsedfunctionplot.cpp +++ b/examples/parsedfunctionplot/parsedfunctionplot.cpp @@ -18,7 +18,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/rgbimageplot/rgbimageplot.cpp b/examples/rgbimageplot/rgbimageplot.cpp index 421351b635..115e43f7d7 100644 --- a/examples/rgbimageplot/rgbimageplot.cpp +++ b/examples/rgbimageplot/rgbimageplot.cpp @@ -14,7 +14,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/rgbimageplot_qt/rgbimageplot_qt.cpp b/examples/rgbimageplot_qt/rgbimageplot_qt.cpp index 9acafffde1..ece9cc3323 100644 --- a/examples/rgbimageplot_qt/rgbimageplot_qt.cpp +++ b/examples/rgbimageplot_qt/rgbimageplot_qt.cpp @@ -15,7 +15,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/simpletest/simpletest.cpp b/examples/simpletest/simpletest.cpp index 1ca6af385b..04bbf9a381 100644 --- a/examples/simpletest/simpletest.cpp +++ b/examples/simpletest/simpletest.cpp @@ -12,13 +12,15 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/speed/speed.cpp b/examples/speed/speed.cpp index 6ea8023afe..3ed2f48352 100644 --- a/examples/speed/speed.cpp +++ b/examples/speed/speed.cpp @@ -8,7 +8,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/stackedbars/stackedbars.cpp b/examples/stackedbars/stackedbars.cpp index a343d28b9c..297e75b696 100644 --- a/examples/stackedbars/stackedbars.cpp +++ b/examples/stackedbars/stackedbars.cpp @@ -103,7 +103,8 @@ void addGraph(JKQTPlotter& plot, bool swapXY) { int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/stepplots/stepplots.cpp b/examples/stepplots/stepplots.cpp index a86d82d508..f8af572e42 100644 --- a/examples/stepplots/stepplots.cpp +++ b/examples/stepplots/stepplots.cpp @@ -13,7 +13,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/styledboxplot/test_styledboxplot.cpp b/examples/styledboxplot/test_styledboxplot.cpp index 433236978e..8e8009d62f 100644 --- a/examples/styledboxplot/test_styledboxplot.cpp +++ b/examples/styledboxplot/test_styledboxplot.cpp @@ -12,7 +12,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/styling/test_styling_main.cpp b/examples/styling/test_styling_main.cpp index 0a5c6beb30..c75e9d8af2 100644 --- a/examples/styling/test_styling_main.cpp +++ b/examples/styling/test_styling_main.cpp @@ -6,7 +6,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/symbols_and_errors/symbols_and_errors.cpp b/examples/symbols_and_errors/symbols_and_errors.cpp index a9c4548b35..be55322f33 100644 --- a/examples/symbols_and_errors/symbols_and_errors.cpp +++ b/examples/symbols_and_errors/symbols_and_errors.cpp @@ -14,7 +14,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/symbols_and_styles/symbols_and_styles.cpp b/examples/symbols_and_styles/symbols_and_styles.cpp index c2574323d5..6112b57e9c 100644 --- a/examples/symbols_and_styles/symbols_and_styles.cpp +++ b/examples/symbols_and_styles/symbols_and_styles.cpp @@ -13,7 +13,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/ui/ui.cpp b/examples/ui/ui.cpp index c39fa12c82..bd85b1254e 100644 --- a/examples/ui/ui.cpp +++ b/examples/ui/ui.cpp @@ -5,7 +5,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/user_interaction/test_user_interaction_main.cpp b/examples/user_interaction/test_user_interaction_main.cpp index 25a6493ddc..b6d87d542d 100644 --- a/examples/user_interaction/test_user_interaction_main.cpp +++ b/examples/user_interaction/test_user_interaction_main.cpp @@ -5,7 +5,8 @@ int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/examples/violinplot/violinplot.cpp b/examples/violinplot/violinplot.cpp index 25aabd9321..35295a36ae 100644 --- a/examples/violinplot/violinplot.cpp +++ b/examples/violinplot/violinplot.cpp @@ -164,7 +164,8 @@ JKQTPlotter* showPlot() { int main(int argc, char* argv[]) { -#if QT_VERSION >= 0x050600 +#if QT_VERSION >= QT_VERSION_CHECK(5,6,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps #endif diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 7ae1068c09..2a6c6d226f 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -10,7 +10,10 @@ message( STATUS "Version: ${PROJECT_VERSION}") if (CMAKE_BUILD_TYPE) message( STATUS "Build type: ${CMAKE_BUILD_TYPE}") endif(CMAKE_BUILD_TYPE) -message( STATUS "Using compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" ) +message( STATUS "Using CMake: ${CMAKE_VERSION}") +message( STATUS " Generator: ${CMAKE_GENERATOR}") +message( STATUS "Using compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, platform: ${CMAKE_CXX_PLATFORM_ID}" ) +message( STATUS "C++ Standard: C++${CMAKE_CXX_STANDARD}, required: ${CMAKE_CXX_STANDARD_REQUIRED}" ) message( STATUS "Architecture: ${CMAKE_CXX_LIBRARY_ARCHITECTURE} / ${CMAKE_LIBRARY_ARCHITECTURE}" ) message( STATUS "System Name: ${CMAKE_SYSTEM_NAME}" ) message( STATUS "Processor Name: ${CMAKE_SYSTEM_PROCESSOR}" ) diff --git a/lib/jkqtcommon/CMakeLists.txt b/lib/jkqtcommon/CMakeLists.txt index 7d1b4a271d..acdc3044e2 100644 --- a/lib/jkqtcommon/CMakeLists.txt +++ b/lib/jkqtcommon/CMakeLists.txt @@ -100,9 +100,15 @@ if(JKQtPlotter_BUILD_SHARED_LIBS) target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport) target_compile_definitions(${libsh_name} PUBLIC JKQTCOMMON_LIB_IN_DLL) target_compile_definitions(${libsh_name} PRIVATE JKQTCOMMON_LIB_EXPORT_LIBRARY) - set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) - set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) - target_compile_features(${libsh_name} PUBLIC cxx_std_11) + if(${QT_VERSION_MAJOR} VERSION_LESS "6") + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${libsh_name} PUBLIC cxx_std_11) + else() + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17) + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${libsh_name} PUBLIC cxx_std_17) + endif() if(MINGW) # COMPILER-SETTINGS FOR MINGW target_compile_options(${libsh_name} PUBLIC -fexceptions) @@ -125,9 +131,15 @@ if(JKQtPlotter_BUILD_STATIC_LIBS) add_library(${lib_name} STATIC ${SOURCES} ${HEADERS}) set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") - set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) - set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) - target_compile_features(${lib_name} PUBLIC cxx_std_11) + if(${QT_VERSION_MAJOR} VERSION_LESS "6") + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${lib_name} PUBLIC cxx_std_11) + else() + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17) + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${lib_name} PUBLIC cxx_std_17) + endif() if(MINGW) # COMPILER-SETTINGS FOR MINGW target_compile_options(${lib_name} PUBLIC -fexceptions) diff --git a/lib/jkqtcommon/LibTarget.cmake.in b/lib/jkqtcommon/LibTarget.cmake.in index 5d5d6ef4dd..9689badc63 100644 --- a/lib/jkqtcommon/LibTarget.cmake.in +++ b/lib/jkqtcommon/LibTarget.cmake.in @@ -7,8 +7,7 @@ # package requires Qt 5/6 -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) +find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) # include auto-generated targets.cmake file include("${CMAKE_CURRENT_LIST_DIR}/@JKQTP_CURRENT_TARGET_FILENAME@") \ No newline at end of file diff --git a/lib/jkqtcommon/jkqttools.cpp b/lib/jkqtcommon/jkqttools.cpp index da3230e746..cfd8ab54f6 100644 --- a/lib/jkqtcommon/jkqttools.cpp +++ b/lib/jkqtcommon/jkqttools.cpp @@ -31,6 +31,9 @@ #else # include #endif +#if QT_VERSION>=QT_VERSION_CHECK(6,0,0) +# include +#endif void jksaveWidgetGeometry(QSettings& settings, QWidget* widget, const QString& prefix) { settings.setValue(prefix+"pos", widget->pos()); @@ -102,20 +105,19 @@ QString jkVariantListToString(const QList& data, const QString& separa else r=r+v.toString(); #else -# define QVARIANT_TYPESBASE QVariant switch (v.type()) { - case QVARIANT_TYPESBASE::Bool: r=r+loc.toString(v.toBool()); break; - case QVARIANT_TYPESBASE::Char: r=r+loc.toString(v.toInt()); break; - case QVARIANT_TYPESBASE::Date: r=r+loc.toString(v.toDate()); break; - case QVARIANT_TYPESBASE::DateTime: r=r+loc.toString(v.toDateTime()); break; - case QVARIANT_TYPESBASE::Double: r=r+loc.toString(v.toDouble()); break; - case QVARIANT_TYPESBASE::Int: r=r+loc.toString(v.toInt()); break; - case QVARIANT_TYPESBASE::LongLong: r=r+loc.toString(v.toLongLong()); break; - case QVARIANT_TYPESBASE::String: r=r+QString("\"%1\"").arg(v.toString().replace("\"", "_").replace("\t", " ").replace("\r", "").replace("\n", " ").replace(",", " ").replace(";", " ")); break; - case QVARIANT_TYPESBASE::Time: r=r+loc.toString(v.toTime()); break; - case QVARIANT_TYPESBASE::UInt: r=r+loc.toString(v.toUInt()); break; - case QVARIANT_TYPESBASE::ULongLong: r=r+loc.toString(v.toULongLong()); break; + case QVariant::Bool: r=r+loc.toString(v.toBool()); break; + case QVariant::Char: r=r+loc.toString(v.toInt()); break; + case QVariant::Date: r=r+loc.toString(v.toDate()); break; + case QVariant::DateTime: r=r+loc.toString(v.toDateTime()); break; + case QVariant::Double: r=r+loc.toString(v.toDouble()); break; + case QVariant::Int: r=r+loc.toString(v.toInt()); break; + case QVariant::LongLong: r=r+loc.toString(v.toLongLong()); break; + case QVariant::String: r=r+QString("\"%1\"").arg(v.toString().replace("\"", "_").replace("\t", " ").replace("\r", "").replace("\n", " ").replace(",", " ").replace(";", " ")); break; + case QVariant::Time: r=r+loc.toString(v.toTime()); break; + case QVariant::UInt: r=r+loc.toString(v.toUInt()); break; + case QVariant::ULongLong: r=r+loc.toString(v.toULongLong()); break; //case : r=r+loc.toString(v.); break; default: r=r+v.toString(); break; } @@ -266,3 +268,12 @@ Qt::MouseButton jkqtp_String2MouseButton(const QString &button) if (but=="EXTRA24") return Qt::ExtraButton24; return Qt::NoButton; } + +quint16 jkqtp_checksum(const void *data, size_t len) +{ +#if QT_VERSION>=QT_VERSION_CHECK(6,0,0) + return qChecksum(QByteArrayView(static_cast(data), len)); +#else + return qChecksum(data, len); +#endif +} diff --git a/lib/jkqtcommon/jkqttools.h b/lib/jkqtcommon/jkqttools.h index 37dcc6a2ca..7d2b4717a7 100644 --- a/lib/jkqtcommon/jkqttools.h +++ b/lib/jkqtcommon/jkqttools.h @@ -134,6 +134,12 @@ JKQTCOMMON_LIB_EXPORT QString jkqtp_MouseButton2String(Qt::MouseButton button, b * \see jkqtp_MouseButton2String() */ JKQTCOMMON_LIB_EXPORT Qt::MouseButton jkqtp_String2MouseButton(const QString &button); +/** \brief convert a QString (created by jkqtp_MouseButton2String() ) to Qt::MouseButton + * \ingroup tools + * + * \see jkqtp_MouseButton2String() + */ +JKQTCOMMON_LIB_EXPORT quint16 jkqtp_checksum(const void* data, size_t len); #endif // JKQTTOOLS_H diff --git a/lib/jkqtfastplotter/CMakeLists.txt b/lib/jkqtfastplotter/CMakeLists.txt index 39fb3a8201..a5af5f8de7 100644 --- a/lib/jkqtfastplotter/CMakeLists.txt +++ b/lib/jkqtfastplotter/CMakeLists.txt @@ -21,7 +21,7 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Set up source files set(SOURCES - jkqtfastplotter.cpp + ${CMAKE_CURRENT_LIST_DIR}/jkqtfastplotter.cpp ) set(HEADERS @@ -40,10 +40,17 @@ if(JKQtPlotter_BUILD_SHARED_LIBS) set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::OpenGL JKQTCommonSharedLib) + if(${QT_VERSION_MAJOR} VERSION_LESS "6") + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${libsh_name} PUBLIC cxx_std_11) + else() + target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets) + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17) + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${libsh_name} PUBLIC cxx_std_17) + endif() target_compile_definitions(${libsh_name} PUBLIC JKQTFASTPLOTTER_LIB_IN_DLL) - set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) - set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) - target_compile_features(${libsh_name} PUBLIC cxx_std_11) if(MINGW) # COMPILER-SETTINGS FOR MINGW target_compile_options(${libsh_name} PUBLIC -fexceptions) @@ -67,8 +74,6 @@ if(JKQtPlotter_BUILD_STATIC_LIBS) add_library(${lib_name} STATIC ${SOURCES} ${RESOURCES} ${HEADERS}) set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") - set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) - set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) if(MINGW) # COMPILER-SETTINGS FOR MINGW target_compile_options(${lib_name} PUBLIC -fexceptions) @@ -77,10 +82,16 @@ if(JKQtPlotter_BUILD_STATIC_LIBS) target_compile_options(${lib_name} PUBLIC /EHsc) target_compile_definitions(${lib_name} PUBLIC NOMINMAX) endif() - target_compile_features(${lib_name} PUBLIC cxx_std_11) target_link_libraries(${lib_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::OpenGL JKQTCommonLib) - if(${QT_VERSION_MAJOR}>=6) - target_link_libraries(${lib_name} PUBLIC t${QT_VERSION_MAJOR}::OpenGLWidgets) + if(${QT_VERSION_MAJOR} VERSION_LESS "6") + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${lib_name} PUBLIC cxx_std_11) + else() + target_link_libraries(${lib_name} PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets) + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17) + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${lib_name} PUBLIC cxx_std_17) endif() target_include_directories(${lib_name} PUBLIC $ diff --git a/lib/jkqtfastplotter/LibTarget.cmake.in b/lib/jkqtfastplotter/LibTarget.cmake.in index fc4856b249..eab45b1aa8 100644 --- a/lib/jkqtfastplotter/LibTarget.cmake.in +++ b/lib/jkqtfastplotter/LibTarget.cmake.in @@ -7,8 +7,10 @@ # package requires Qt 5/6 -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) +find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) +if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "6") + find_package(Qt@QT_VERSION_MAJOR@ REQUIRED COMPONENTS OpenGLWidgets) +endif() find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) # include auto-generated targets.cmake file diff --git a/lib/jkqtmathtext/CMakeLists.txt b/lib/jkqtmathtext/CMakeLists.txt index b0e2e0e969..53d56cba10 100644 --- a/lib/jkqtmathtext/CMakeLists.txt +++ b/lib/jkqtmathtext/CMakeLists.txt @@ -47,9 +47,15 @@ if(JKQtPlotter_BUILD_SHARED_LIBS) target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport JKQTCommonSharedLib) target_compile_definitions(${libsh_name} PUBLIC JKQTMATHTEXT_LIB_IN_DLL) target_compile_definitions(${libsh_name} PRIVATE JKQTMATHTEXT_LIB_EXPORT_LIBRARY) - set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) - set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) - target_compile_features(${libsh_name} PUBLIC cxx_std_11) + if(${QT_VERSION_MAJOR} VERSION_LESS "6") + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${libsh_name} PUBLIC cxx_std_11) + else() + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17) + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${libsh_name} PUBLIC cxx_std_17) + endif() if(MINGW) # COMPILER-SETTINGS FOR MINGW target_compile_options(${libsh_name} PUBLIC -fexceptions) @@ -75,9 +81,15 @@ if(JKQtPlotter_BUILD_STATIC_LIBS) add_library(${lib_name} STATIC ${SOURCES} ${RESOURCES} ${HEADERS}) set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") - set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) - set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) - target_compile_features(${lib_name} PUBLIC cxx_std_11) + if(${QT_VERSION_MAJOR} VERSION_LESS "6") + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${lib_name} PUBLIC cxx_std_11) + else() + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17) + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${lib_name} PUBLIC cxx_std_17) + endif() if(MINGW) # COMPILER-SETTINGS FOR MINGW target_compile_options(${lib_name} PUBLIC -fexceptions) diff --git a/lib/jkqtmathtext/LibTarget.cmake.in b/lib/jkqtmathtext/LibTarget.cmake.in index eb678808a1..697c6c65f5 100644 --- a/lib/jkqtmathtext/LibTarget.cmake.in +++ b/lib/jkqtmathtext/LibTarget.cmake.in @@ -7,8 +7,7 @@ # package requires Qt 5/6 -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) +find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h index c6da1fd949..e2e9c9b36e 100644 --- a/lib/jkqtmathtext/jkqtmathtext.h +++ b/lib/jkqtmathtext/jkqtmathtext.h @@ -1194,14 +1194,16 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject { }; - +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +inline size_t qHash(const JKQTMathText::tbrDataH& data, size_t /*seed=0*/) { +#else inline uint qHash(const JKQTMathText::tbrDataH& data) { - return qHash(data.f.family())+qHash(data.text); +#endif + return qHash(data.f.family())+qHash(data.text); } - /*! \brief A QLabel-derived class that draws an equation with LaTeX markup using JKQTMathText \ingroup jkqtmathtext diff --git a/lib/jkqtplotter/CMakeLists.txt b/lib/jkqtplotter/CMakeLists.txt index 8eded3f001..d8a0067f67 100644 --- a/lib/jkqtplotter/CMakeLists.txt +++ b/lib/jkqtplotter/CMakeLists.txt @@ -202,9 +202,15 @@ if(JKQtPlotter_BUILD_SHARED_LIBS) set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") target_link_libraries(${libsh_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Xml JKQTCommonSharedLib JKQTMathTextSharedLib) - set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) - set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) - target_compile_features(${libsh_name} PUBLIC cxx_std_11) + if(${QT_VERSION_MAJOR} VERSION_LESS "6") + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11) + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${libsh_name} PUBLIC cxx_std_11) + else() + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 17) + set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${libsh_name} PUBLIC cxx_std_17) + endif() target_compile_definitions(${libsh_name} PUBLIC JKQTPLOTTER_LIB_IN_DLL) target_compile_definitions(${libsh_name} PRIVATE JKQTPLOTTER_LIB_EXPORT_LIBRARY) if(MINGW) @@ -229,8 +235,15 @@ if(JKQtPlotter_BUILD_STATIC_LIBS) add_library(${lib_name} STATIC ${SOURCES_BASE} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${RESOURCES} ${HEADERS_BASE} ${HEADERS_GRAPHS} ${HEADERS_GUI}) set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") - set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) - set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + if(${QT_VERSION_MAJOR} VERSION_LESS "6") + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${lib_name} PUBLIC cxx_std_11) + else() + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 17) + set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE) + target_compile_features(${lib_name} PUBLIC cxx_std_17) + endif() if(MINGW) # COMPILER-SETTINGS FOR MINGW target_compile_options(${lib_name} PUBLIC -fexceptions) @@ -239,7 +252,6 @@ if(JKQtPlotter_BUILD_STATIC_LIBS) target_compile_options(${lib_name} PUBLIC /EHsc) target_compile_definitions(${lib_name} PUBLIC NOMINMAX) endif() - target_compile_features(${lib_name} PUBLIC cxx_std_11) target_include_directories(${lib_name} PUBLIC $ $ diff --git a/lib/jkqtplotter/LibTarget.cmake.in b/lib/jkqtplotter/LibTarget.cmake.in index 084bd3c66a..0145dd55e1 100644 --- a/lib/jkqtplotter/LibTarget.cmake.in +++ b/lib/jkqtplotter/LibTarget.cmake.in @@ -6,8 +6,7 @@ # # package requires Qt 5/6 -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) +find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGL REQUIRED) find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) find_package(JKQTMathText@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) diff --git a/lib/jkqtplotter/graphs/jkqtpcontour.cpp b/lib/jkqtplotter/graphs/jkqtpcontour.cpp index a356f044ea..95b1ee0483 100644 --- a/lib/jkqtplotter/graphs/jkqtpcontour.cpp +++ b/lib/jkqtplotter/graphs/jkqtpcontour.cpp @@ -25,6 +25,7 @@ #include "jkqtcommon/jkqtpenhancedpainter.h" #include "jkqtplotter/jkqtplotter.h" #include "jkqtcommon/jkqtpgeometrytools.h" +#include "jkqtcommon/jkqttools.h" #include #include #include @@ -63,7 +64,7 @@ void JKQTPContourPlot::draw(JKQTPEnhancedPainter &painter) int64_t colChecksum=-1; if (data && Nx*Ny>0) { - colChecksum=static_cast(qChecksum(reinterpret_cast(data), static_cast(Nx)*static_cast(Ny)* static_cast(getSampleSize()/sizeof(char)))); + colChecksum=static_cast(jkqtp_checksum(reinterpret_cast(data), static_cast(Nx)*static_cast(Ny)* static_cast(getSampleSize()/sizeof(char)))); } /*if (parent && parent->getDatastore() && imageColumn>=0) { colChecksum=static_cast(parent->getDatastore()->getColumnChecksum(imageColumn)); diff --git a/lib/jkqtplotter/gui/jkqtpenhancedtableview.cpp b/lib/jkqtplotter/gui/jkqtpenhancedtableview.cpp index 30da6a05b4..edfcf53bab 100644 --- a/lib/jkqtplotter/gui/jkqtpenhancedtableview.cpp +++ b/lib/jkqtplotter/gui/jkqtpenhancedtableview.cpp @@ -129,6 +129,26 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead) if (sel.size()==1) { QVariant vdata=sel[0].data(copyrole); QString txt=""; +#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0)) + switch (vdata.typeId()) { + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: + case QMetaType::Bool: + txt=vdata.toString(); + break; + case QMetaType::Double: + txt=loc.toString(vdata.toDouble()); + break; + case QMetaType::QPointF: + txt=loc.toString(vdata.toPointF().x()); + break; + default: + txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); + break; + } +#else switch (vdata.type()) { case QVariant::Int: case QVariant::LongLong: @@ -147,6 +167,7 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead) txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); break; } +#endif QApplication::clipboard()->setText(txt); } else { QSet rows, cols; @@ -210,6 +231,26 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead) int c=collist.indexOf(sel[i].column()); QVariant vdata=sel[i].data(copyrole); QString txt=""; +#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0)) + switch (vdata.typeId()) { + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: + case QMetaType::Bool: + txt=vdata.toString(); + break; + case QMetaType::Double: + txt=loc.toString(vdata.toDouble()); + break; + case QMetaType::QPointF: + txt=loc.toString(vdata.toPointF().x()); + break; + default: + txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); + break; + } +#else switch (vdata.type()) { case QVariant::Int: case QVariant::LongLong: @@ -228,6 +269,7 @@ void JKQTPEnhancedTableView::copySelectionToExcel(int copyrole, bool storeHead) txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); break; } +#endif int shift=0; if (storeHead) shift=1; if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+shift][c+shift]=txt; @@ -256,6 +298,26 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co if (sel.size()==1) { QVariant vdata=sel[0].data(copyrole); QString txt=""; +#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0)) + switch (vdata.typeId()) { + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: + case QMetaType::Bool: + txt=vdata.toString(); + break; + case QMetaType::Double: + txt=JKQTPDoubleToQString(vdata.toDouble(), 15, 'g', decimalpoint); + break; + case QMetaType::QPointF: + txt=JKQTPDoubleToQString(vdata.toPointF().x(), 15, 'g', decimalpoint); + break; + default: + txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); + break; + } +#else switch (vdata.type()) { case QVariant::Int: case QVariant::LongLong: @@ -274,6 +336,7 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); break; } +#endif QApplication::clipboard()->setText(txt); } else { QSet rows, cols; @@ -337,6 +400,26 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co int c=collist.indexOf(sel[i].column()); QVariant vdata=sel[i].data(copyrole); QString txt=""; +#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0)) + switch (vdata.typeId()) { + case QMetaType::Int: + case QMetaType::LongLong: + case QMetaType::UInt: + case QMetaType::ULongLong: + case QMetaType::Bool: + txt=vdata.toString(); + break; + case QMetaType::Double: + txt=JKQTPDoubleToQString(vdata.toDouble(), 15, 'g', decimalpoint); + break; + case QMetaType::QPointF: + txt=JKQTPDoubleToQString(vdata.toPointF().x(), 15, 'g', decimalpoint); + break; + default: + txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); + break; + } +#else switch (vdata.type()) { case QVariant::Int: case QVariant::LongLong: @@ -355,6 +438,7 @@ void JKQTPEnhancedTableView::copySelectionToCSV(int copyrole, bool storeHead, co txt=QString("\"%1\"").arg(vdata.toString().replace('"', "''").replace('\n', "\\n ").replace('\r', "\\r ").replace('\t', " ")); break; } +#endif int shift=0; if (storeHead) shift=1; if ((r>=0) && (c>=0) && (r<=data.size()) && (c<=colcnt))data[r+shift][c+shift]=txt; @@ -568,7 +652,12 @@ QSizeF JKQTPEnhancedTableView::getTotalSize() const void JKQTPEnhancedTableView::paint(QPainter &painter, double scale, int page, double hhh, double vhw, const QList& pageCols, const QList& pageRows, QPrinter* p) { painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); - QStyleOptionViewItem option = viewOptions(); + QStyleOptionViewItem option; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + initViewItemOption(&option); +#else + option = viewOptions(); +#endif painter.scale(scale, scale); QPen headerPen("black"); headerPen.setWidth(2); diff --git a/lib/jkqtplotter/jkqtpbaseplotter.cpp b/lib/jkqtplotter/jkqtpbaseplotter.cpp index fe172286fb..cbfa30c1dc 100644 --- a/lib/jkqtplotter/jkqtpbaseplotter.cpp +++ b/lib/jkqtplotter/jkqtpbaseplotter.cpp @@ -778,29 +778,30 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){ internalPlotKeyBorderBottom=0; internalPlotKeyBorderLeft=0; internalPlotKeyBorderRight=0; + const qreal Xwid=kfm.boundingRect('X').width(); if (plotterStyle.keyStyle.position==JKQTPKeyOutsideTopRight) { - internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2; + internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2; internalPlotBorderTop = internalPlotBorderTop + internalPlotKeyBorderTop; } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideTopLeft) { - internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2; + internalPlotKeyBorderTop=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2; internalPlotBorderTop = internalPlotBorderTop + internalPlotKeyBorderTop; } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideLeftTop) { - internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2; + internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2; internalPlotBorderLeft = internalPlotBorderLeft + internalPlotKeyBorderLeft; } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideLeftBottom) { - internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2; + internalPlotKeyBorderLeft=keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2; internalPlotBorderLeft = internalPlotBorderLeft + internalPlotKeyBorderLeft; } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideBottomRight) { - internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2; + internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2; internalPlotBorderBottom = internalPlotBorderBottom + internalPlotKeyBorderBottom; } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideBottomLeft) { - internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*kfm.width('X')+2; + internalPlotKeyBorderBottom=keyHeight+2*plotterStyle.keyStyle.yMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.yOffset*Xwid+2; internalPlotBorderBottom = internalPlotBorderBottom + internalPlotKeyBorderBottom; } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideRightTop) { - internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2; + internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2; internalPlotBorderRight = internalPlotBorderRight + internalPlotKeyBorderRight; } else if (plotterStyle.keyStyle.position==JKQTPKeyOutsideRightBottom) { - internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*kfm.width('X')+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*kfm.width('X')+2; + internalPlotKeyBorderRight = keyWidth+2*plotterStyle.keyStyle.xMargin*Xwid+ceil(2*plotterStyle.keyStyle.frameWidth)+plotterStyle.keyStyle.xOffset*Xwid+2; internalPlotBorderRight = internalPlotBorderRight + internalPlotKeyBorderRight; } @@ -1052,13 +1053,14 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) { QFont kf(plotterStyle.defaultFontName, 10); kf.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); QFontMetricsF kfm(kf); + const qreal Xwid=kfm.boundingRect('X').width(); // get the size of the key and if keyWidth>0 && keyHeight>0 draw the frame and the contents double keyWidth=0; double keyHeight=0; getKeyExtent(painter, &keyWidth, &keyHeight); - double keyRectangleWidth=keyWidth+2.0*plotterStyle.keyStyle.xMargin*kfm.width('X')+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier; - double keyRectangleHeight=keyHeight+2.0*plotterStyle.keyStyle.yMargin*kfm.width('X')+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier; + double keyRectangleWidth=keyWidth+2.0*plotterStyle.keyStyle.xMargin*Xwid+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier; + double keyRectangleHeight=keyHeight+2.0*plotterStyle.keyStyle.yMargin*Xwid+2.0*plotterStyle.keyStyle.frameWidth*lineWidthPrintMultiplier; if ((keyWidth>0) && (keyHeight>0)) { // key position @@ -1067,64 +1069,64 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) { // default: inside top-right double x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; - double x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + double x=x0-plotterStyle.keyStyle.xOffset*Xwid; double y0=internalPlotBorderTop; - double y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); + double y=y0+plotterStyle.keyStyle.yOffset*Xwid; switch(plotterStyle.keyStyle.position) { case JKQTPKeyOutsideTopRight: x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth; - x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0-plotterStyle.keyStyle.xOffset*Xwid; y0=internalTitleHeight; - y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0+plotterStyle.keyStyle.yOffset*Xwid; break; case JKQTPKeyOutsideTopLeft: x0=internalPlotBorderLeft; - x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0+plotterStyle.keyStyle.xOffset*Xwid; y0=internalTitleHeight; - y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0+plotterStyle.keyStyle.yOffset*Xwid; break; case JKQTPKeyOutsideBottomRight: x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; - x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0-plotterStyle.keyStyle.xOffset*Xwid; y0=internalPlotBorderTop+internalPlotHeight+internalPlotBorderBottom-keyRectangleHeight; - y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0-plotterStyle.keyStyle.yOffset*Xwid; break; case JKQTPKeyOutsideBottomLeft: x0=internalPlotBorderLeft; - x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0+plotterStyle.keyStyle.xOffset*Xwid; y0=internalPlotBorderTop+internalPlotHeight+internalPlotBorderBottom-keyRectangleHeight; - y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0-plotterStyle.keyStyle.yOffset*Xwid; break; case JKQTPKeyOutsideRightTop: x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth; - x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0-plotterStyle.keyStyle.xOffset*Xwid; y0=internalPlotBorderTop; - y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0+plotterStyle.keyStyle.yOffset*Xwid; break; case JKQTPKeyOutsideRightBottom: x0=internalPlotBorderLeft+internalPlotWidth+internalPlotBorderRight-keyRectangleWidth; - x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0-plotterStyle.keyStyle.xOffset*Xwid; y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; - y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0-plotterStyle.keyStyle.yOffset*Xwid; break; case JKQTPKeyOutsideLeftTop: x0=0; - x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0+plotterStyle.keyStyle.xOffset*Xwid; y0=internalPlotBorderTop; - y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0+plotterStyle.keyStyle.yOffset*Xwid; break; case JKQTPKeyOutsideLeftBottom: x0=0; - x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0+plotterStyle.keyStyle.xOffset*Xwid; y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; - y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0-plotterStyle.keyStyle.yOffset*Xwid; break; @@ -1132,27 +1134,27 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) { case JKQTPKeyInsideBottomRight: x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; - x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0-plotterStyle.keyStyle.xOffset*Xwid; y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; - y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0-plotterStyle.keyStyle.yOffset*Xwid; break; case JKQTPKeyInsideBottomLeft: x0=internalPlotBorderLeft; - x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0+plotterStyle.keyStyle.xOffset*Xwid; y0=internalPlotBorderTop+internalPlotHeight-keyRectangleHeight; - y=y0-plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0-plotterStyle.keyStyle.yOffset*Xwid; break; case JKQTPKeyInsideTopLeft: x0=internalPlotBorderLeft; - x=x0+plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0+plotterStyle.keyStyle.xOffset*Xwid; y0=internalPlotBorderTop; - y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0+plotterStyle.keyStyle.yOffset*Xwid; break; case JKQTPKeyInsideTopRight: x0=internalPlotBorderLeft+internalPlotWidth-keyRectangleWidth; - x=x0-plotterStyle.keyStyle.xOffset*kfm.width('X'); + x=x0-plotterStyle.keyStyle.xOffset*Xwid; y0=internalPlotBorderTop; - y=y0+plotterStyle.keyStyle.yOffset*kfm.width('X'); + y=y0+plotterStyle.keyStyle.yOffset*Xwid; break; } QRectF rectKey; @@ -1177,8 +1179,8 @@ void JKQTBasePlotter::drawKey(JKQTPEnhancedPainter& painter) { } else { painter.drawRoundedRect(rectKey, pt2px(painter, plotterStyle.keyStyle.frameRounding), pt2px(painter, plotterStyle.keyStyle.frameRounding)); } - y=y+plotterStyle.keyStyle.yMargin*kfm.width('X')+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0; - x=x+plotterStyle.keyStyle.xMargin*kfm.width('X')+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0; + y=y+plotterStyle.keyStyle.yMargin*Xwid+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0; + x=x+plotterStyle.keyStyle.xMargin*Xwid+plotterStyle.keyStyle.frameWidth*lineWidthMultiplier/2.0; painter.setPen(pf); @@ -1229,7 +1231,9 @@ void JKQTBasePlotter::drawPlot(JKQTPEnhancedPainter& painter) { if (plotterStyle.widgetBackgroundBrush!=QBrush(Qt::transparent)) painter.fillRect(QRectF(0,0,widgetWidth/paintMagnification, widgetHeight/paintMagnification), plotterStyle.widgetBackgroundBrush); } QRectF rPlotBack(internalPlotBorderLeft, internalPlotBorderTop, internalPlotWidth, internalPlotHeight); +#if QT_VERSIONpalette()); // Set background colour to black - p.setColor(QPalette::Background, Qt::darkGray); + p.setColor(QPalette::Window, Qt::darkGray); scroll->setPalette(p); } exportPreviewLabel=new QLabel(scroll); @@ -1751,7 +1755,7 @@ bool JKQTBasePlotter::exportpreview(QSizeF pageSize, bool unitIsMM) { { QPalette p(exportPreviewLabel->palette()); // Set background colour to black - p.setColor(QPalette::Background, Qt::darkGray); + p.setColor(QPalette::Window, Qt::darkGray); exportPreviewLabel->setPalette(p); } @@ -3306,8 +3310,8 @@ void JKQTBasePlotter::copyData() { QTextStream txt(&result); QLocale loc=QLocale::system(); loc.setNumberOptions(QLocale::OmitGroupSeparator); - QChar dp=loc.decimalPoint(); - QString sep="\t"; + const auto dp=loc.decimalPoint(); + const QString sep="\t"; datastore->saveCSV(txt, cols, sep, QString(dp), " ", "\""); txt.flush(); } @@ -4140,21 +4144,22 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d #ifdef JKQTBP_AUTOTIMER jkaaot.write(QString("one-col: graph %1: %2").arg(i).arg(g->getTitle())); #endif + const auto Xwid=kfm.boundingRect('X').width(); if (!g->getTitle().isEmpty() && g->isVisible()) { QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter); - double itheight=qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), fs.height()); - QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*kfm.width('X'), itheight-3.0*lineWidthMultiplier); + double itheight=qMax(plotterStyle.keyStyle.itemHeight*Xwid, fs.height()); + QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*Xwid, itheight-3.0*lineWidthMultiplier); g->drawKeyMarker(painter, markerRect); mathText.setFontColor(plotterStyle.keyStyle.textColor); mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName); mathText.parse(g->getTitle()); - QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),y, key_text_width, itheight); + QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*Xwid,y, key_text_width, itheight); mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); //if (itheightgetTitle())); #endif if (!g->getTitle().isEmpty() && g->isVisible()) { + const auto Xwid=kfm.boundingRect('X').width(); QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter); - double itheight=qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), fs.height()); - QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*kfm.width('X'), itheight-3.0*lineWidthMultiplier); + double itheight=qMax(plotterStyle.keyStyle.itemHeight*Xwid, fs.height()); + QRectF markerRect(x, y+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*Xwid, itheight-3.0*lineWidthMultiplier); g->drawKeyMarker(painter, markerRect); mathText.setFontColor(plotterStyle.keyStyle.textColor); mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName); mathText.parse(g->getTitle()); - QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),y, fs.width(), itheight); + QRectF txtRect(x+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*Xwid,y, fs.width(), itheight); mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); if (plotterStyle.debugShowRegionBoxes) { painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();}); @@ -4203,11 +4209,11 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d } //if (itheight(plotWidth)/static_cast(key_item_width*kfm.width('X'))); + //int columns=floor(static_cast(plotWidth)/static_cast(key_item_width*Xwid)); bool colfirst=true; if (plotterStyle.keyStyle.position==JKQTPKeyInsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyInsideTopRight @@ -4219,6 +4225,7 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d int c=1; double xx=x; double yy=y; + const auto Xwid=kfm.boundingRect('X').width(); for (int i=0; igetTitle().isEmpty() && g->isVisible()) { //QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName,plotterStyle.keyStyle.fontSize*fontSizeMultiplier,g->getTitle(),painter);// mt.getSize(painter); - double itheight=qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), key_text_height); - QRectF markerRect(xx, yy+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*kfm.width('X'), itheight-3.0*lineWidthMultiplier); + double itheight=qMax(plotterStyle.keyStyle.itemHeight*Xwid, key_text_height); + QRectF markerRect(xx, yy+1.5*lineWidthMultiplier, plotterStyle.keyStyle.sampleLineLength*Xwid, itheight-3.0*lineWidthMultiplier); g->drawKeyMarker(painter, markerRect); mathText.setFontColor(plotterStyle.keyStyle.textColor); mathText.setFontSize(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); mathText.setFontRomanOrSpecial(plotterStyle.defaultFontName); mathText.parse(g->getTitle()); //QSizeF fs=mt.getSize(painter); - QRectF txtRect(xx+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*kfm.width('X'),yy, key_text_width, key_text_height); + QRectF txtRect(xx+(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation)*Xwid,yy, key_text_width, key_text_height); mathText.draw(painter, Qt::AlignLeft|Qt::AlignVCenter, txtRect); if (plotterStyle.debugShowRegionBoxes) { @@ -4251,26 +4258,26 @@ void JKQTBasePlotter::drawKeyContents(JKQTPEnhancedPainter& painter, double x, d } if (colfirst) { - yy=yy+key_text_height+(plotterStyle.keyStyle.ySeparation)*kfm.width('X'); + yy=yy+key_text_height+(plotterStyle.keyStyle.ySeparation)*Xwid; l++; if (l>lines) { l=1; c++; - xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); - /*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); - else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');*/ + xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid; + /*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*Xwid; + else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;*/ yy=y; } } else { - /*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); - else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X');*/ - xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); + /*if (plotterStyle.keyStyle.autosize) xx=xx+key_text_width+(key_line_length+3.0*plotterStyle.keyStyle.xSeparation)*Xwid; + else xx=xx+(key_item_width+2.0*plotterStyle.keyStyle.xSeparation)*Xwid;*/ + xx=xx+key_text_width+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid; c++; if (c>columns) { c=1; l++; //yy=yy+(key_item_height+plotterStyle.keyStyle.ySeparation)*kfm.height(); - yy=yy+itheight+(plotterStyle.keyStyle.ySeparation)*kfm.width('X'); + yy=yy+itheight+(plotterStyle.keyStyle.ySeparation)*Xwid; xx=x; } } @@ -4292,7 +4299,8 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, f.setFamily(plotterStyle.defaultFontName); f.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier); QFontMetricsF kfm(f); - if (text_height!=nullptr) *text_height=plotterStyle.keyStyle.itemHeight*kfm.width('X'); + const qreal Xwid=kfm.boundingRect('X').width(); + if (text_height!=nullptr) *text_height=plotterStyle.keyStyle.itemHeight*Xwid; if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutOneColumn) { int keyHeight=graphs.size(); double w=0; @@ -4310,18 +4318,18 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName, plotterStyle.keyStyle.fontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter); if (fs.width()>w) w=fs.width(); if (text_height && fs.height()>*text_height) *text_height=fs.height(); - h=h+qMax(plotterStyle.keyStyle.itemHeight*kfm.width('X'), fs.height())+plotterStyle.keyStyle.ySeparation*kfm.width('X'); + h=h+qMax(plotterStyle.keyStyle.itemHeight*Xwid, fs.height())+plotterStyle.keyStyle.ySeparation*Xwid; } } if (plotterStyle.keyStyle.autosize) { - if (width) *width=w+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); - if (text_width!=nullptr) *text_width=w+2.0*kfm.width('X'); + if (width) *width=w+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid; + if (text_width!=nullptr) *text_width=w+2.0*Xwid; } else { - if (width) *width=plotterStyle.keyStyle.itemWidth*kfm.width('X'); - if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*kfm.width('X'); + if (width) *width=plotterStyle.keyStyle.itemWidth*Xwid; + if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*Xwid; } - if (h>plotterStyle.keyStyle.ySeparation*kfm.width('X')) h=h-plotterStyle.keyStyle.ySeparation*kfm.width('X'); - if (height) *height=h;//keyHeight*key_item_height*kfm.width('X'); + if (h>plotterStyle.keyStyle.ySeparation*Xwid) h=h-plotterStyle.keyStyle.ySeparation*Xwid; + if (height) *height=h;//keyHeight*key_item_height*Xwid; if (columns_count) *columns_count=1; if (lines_count) *lines_count=keyHeight; } else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutOneRow) { @@ -4341,19 +4349,19 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, QSizeF fs=getTextSizeSize(plotterStyle.defaultFontName, plotterStyle.keyStyle.fontSize*fontSizeMultiplier, graphs[i]->getTitle(), painter); if (fs.height()>h) h=fs.height(); if (text_width && fs.width()>*text_width) *text_width=fs.width(); - w=w+fs.width()+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'); + w=w+fs.width()+(plotterStyle.keyStyle.sampleLineLength+2.0*plotterStyle.keyStyle.xSeparation)*Xwid; } } - if (h(plotterStyle.keyStyle.xSeparation)*kfm.width('X')) w=w-(plotterStyle.keyStyle.xSeparation)*kfm.width('X'); - if (width) *width=w;//keyHeight*key_item_height*kfm.width('X'); + if (w>(plotterStyle.keyStyle.xSeparation)*Xwid) w=w-(plotterStyle.keyStyle.xSeparation)*Xwid; + if (width) *width=w;//keyHeight*key_item_height*Xwid; if (columns_count) *columns_count=keyWidth; if (lines_count) *lines_count=1; } else if (plotterStyle.keyStyle.layout==JKQTPKeyLayoutMultiColumn) { @@ -4382,12 +4390,12 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, if (text_height) { if (plotterStyle.keyStyle.autosize) *text_height=txtH; - else *text_height=plotterStyle.keyStyle.itemHeight*kfm.width('X'); + else *text_height=plotterStyle.keyStyle.itemHeight*Xwid; } - double columns=floor(double(internalPlotWidth)/(w+(2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*kfm.width('X'))); - if (!plotterStyle.keyStyle.autosize) columns=floor(double(internalPlotWidth)/((plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*kfm.width('X'))); + double columns=floor(double(internalPlotWidth)/(w+(2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*Xwid)); + if (!plotterStyle.keyStyle.autosize) columns=floor(double(internalPlotWidth)/((plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation+plotterStyle.keyStyle.sampleLineLength)*Xwid)); columns=qMin(columns, keyHeight); int lines=static_cast(ceil(static_cast(keyHeight)/static_cast(columns))); lines=jkqtp_roundTo(qMin(static_cast(lines), keyHeight)); @@ -4395,9 +4403,9 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, if (plotterStyle.keyStyle.position==JKQTPKeyInsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyInsideTopRight || plotterStyle.keyStyle.position==JKQTPKeyOutsideTopLeft || plotterStyle.keyStyle.position==JKQTPKeyOutsideTopRight) { if (plotterStyle.keyStyle.autosize) { - lines=static_cast(floor(static_cast(internalPlotHeight)/static_cast(txtH+(plotterStyle.keyStyle.ySeparation)*kfm.width('X')))); + lines=static_cast(floor(static_cast(internalPlotHeight)/static_cast(txtH+(plotterStyle.keyStyle.ySeparation)*Xwid))); } else { - lines=static_cast(floor(static_cast(internalPlotHeight)/static_cast((plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*kfm.width('X')))); + lines=static_cast(floor(static_cast(internalPlotHeight)/static_cast((plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*Xwid))); } columns=static_cast(ceil(static_cast(keyHeight)/static_cast(lines))); lines=jkqtp_roundTo(qMin(static_cast(lines), keyHeight)); @@ -4408,15 +4416,15 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width, if (lines_count) *lines_count=lines; if (plotterStyle.keyStyle.autosize) { - if (width) *width=(w+(plotterStyle.keyStyle.sampleLineLength+3.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X'))*columns; - if (height) *height=lines*(txtH+plotterStyle.keyStyle.ySeparation*kfm.width('X')); - if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*kfm.width('X'); + if (width) *width=(w+(plotterStyle.keyStyle.sampleLineLength+3.0*plotterStyle.keyStyle.xSeparation)*Xwid)*columns; + if (height) *height=lines*(txtH+plotterStyle.keyStyle.ySeparation*Xwid); + if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*Xwid; if (text_width!=nullptr) *text_width=w; } else { - if (width) *width=(plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation)*kfm.width('X')*columns; - if (height) *height=lines*(plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*kfm.width('X'); - if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*kfm.width('X'); - if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*kfm.width('X'); + if (width) *width=(plotterStyle.keyStyle.itemWidth+2.0*plotterStyle.keyStyle.xSeparation)*Xwid*columns; + if (height) *height=lines*(plotterStyle.keyStyle.itemHeight+plotterStyle.keyStyle.ySeparation)*Xwid; + if (lines>0) *height=*height-plotterStyle.keyStyle.ySeparation*Xwid; + if (text_width!=nullptr) *text_width=(plotterStyle.keyStyle.itemWidth-(plotterStyle.keyStyle.sampleLineLength+plotterStyle.keyStyle.xSeparation))*Xwid; } #ifdef SHOW_JKQTPLOTTER_DEBUG qDebug()<<"getKeyExtent(): mult-column: columns="< #include #include @@ -2518,7 +2519,7 @@ quint16 JKQTPColumn::calculateChecksum() const { if (!datastore) return 0; if (!datastore->getItem(datastoreItem)) return 0; - return qChecksum(reinterpret_cast(getPointer(0)), static_cast(getRows()*sizeof(double))); + return jkqtp_checksum(reinterpret_cast(getPointer(0)), static_cast(getRows()*sizeof(double))); } //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/lib/jkqtplotter/jkqtplotter.cpp b/lib/jkqtplotter/jkqtplotter.cpp index 5822d06280..983cd95516 100644 --- a/lib/jkqtplotter/jkqtplotter.cpp +++ b/lib/jkqtplotter/jkqtplotter.cpp @@ -479,7 +479,9 @@ void JKQTPlotter::paintUserAction() { image=oldImage; if (image.width()>0 && image.height()>0 && !image.isNull()) { JKQTPEnhancedPainter painter(&image); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) painter.setRenderHint(JKQTPEnhancedPainter::NonCosmeticDefaultPen, true); +#endif painter.setRenderHint(JKQTPEnhancedPainter::Antialiasing, true); painter.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing, true); painter.setPen(plotterStyle.userActionOverlayPen); @@ -1437,12 +1439,12 @@ QAction* JKQTPlotter::getActMouseLeftAsToolTip() const { void JKQTPlotter::setOverrideMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDragActions action) { - registeredOverrideMouseDragActionModes.insert(qMakePair(button, modifier), action); + registeredOverrideMouseDragActionModes.insert(QPair(button, modifier), action); } void JKQTPlotter::resetOverrideMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier) { - registeredOverrideMouseDragActionModes.remove(qMakePair(button, modifier)); + registeredOverrideMouseDragActionModes.remove(QPair(button, modifier)); } void JKQTPlotter::setContextMenuMode(JKQTPContextMenuModes mode) { @@ -1686,7 +1688,7 @@ JKQTPMouseDragActionsHashMapIterator JKQTPlotter::findMatchingMouseDragAction(Qt if (found) *found=false; JKQTPMouseDragActionsHashMapIterator it=registeredOverrideMouseDragActionModes.cbegin(); while (it!=registeredOverrideMouseDragActionModes.cend() ) { - if (it.key()==qMakePair(button, modifiers)) { + if (it.key()==QPair(button, modifiers)) { if (found) *found=true; return it; } @@ -1694,7 +1696,7 @@ JKQTPMouseDragActionsHashMapIterator JKQTPlotter::findMatchingMouseDragAction(Qt } it=plotterStyle.registeredMouseDragActionModes.cbegin(); while (it!=plotterStyle.registeredMouseDragActionModes.cend() ) { - if (it.key()==qMakePair(button, modifiers)) { + if (it.key()==QPair(button, modifiers)) { if (found) *found=true; return it; } @@ -1707,7 +1709,7 @@ JKQTPMouseDoubleClickActionsHashMapIterator JKQTPlotter::findMatchingMouseDouble { if (found) *found=false; for (JKQTPMouseDoubleClickActionsHashMapIterator it=plotterStyle.registeredMouseDoubleClickActions.cbegin(); it!=plotterStyle.registeredMouseDoubleClickActions.cend(); ++it) { - if (it.key()==qMakePair(button, modifiers)) { + if (it.key()==QPair(button, modifiers)) { if (found) *found=true; return it; } @@ -1738,7 +1740,7 @@ void JKQTPlotter::setPlotUpdateEnabled(bool enable) void JKQTPlotter::registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDragActions action) { - plotterStyle.registeredMouseDragActionModes[qMakePair(button, modifier)]=action; + plotterStyle.registeredMouseDragActionModes[QPair(button, modifier)]=action; if (button==Qt::LeftButton && modifier==Qt::NoModifier) { actMouseLeftAsDefault->setChecked(true); resetMouseLeftAction(); @@ -1747,7 +1749,7 @@ void JKQTPlotter::registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardMo void JKQTPlotter::deregisterMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier) { - plotterStyle.registeredMouseDragActionModes.remove(qMakePair(button, modifier)); + plotterStyle.registeredMouseDragActionModes.remove(QPair(button, modifier)); } void JKQTPlotter::clearAllRegisteredMouseDragActions() @@ -1757,12 +1759,12 @@ void JKQTPlotter::clearAllRegisteredMouseDragActions() void JKQTPlotter::registerMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier, JKQTPMouseDoubleClickActions action) { - plotterStyle.registeredMouseDoubleClickActions[qMakePair(button, modifier)]=action; + plotterStyle.registeredMouseDoubleClickActions[QPair(button, modifier)]=action; } void JKQTPlotter::deregisterMouseDoubleClickAction(Qt::MouseButton button, Qt::KeyboardModifiers modifier) { - plotterStyle.registeredMouseDoubleClickActions.remove(qMakePair(button, modifier)); + plotterStyle.registeredMouseDoubleClickActions.remove(QPair(button, modifier)); } void JKQTPlotter::clearAllRegisteredMouseDoubleClickActions() diff --git a/lib/jkqtplotter/jkqtplotter.h b/lib/jkqtplotter/jkqtplotter.h index 13466d24ea..f10a3f68fa 100644 --- a/lib/jkqtplotter/jkqtplotter.h +++ b/lib/jkqtplotter/jkqtplotter.h @@ -1727,8 +1727,11 @@ QT_BEGIN_NAMESPACE * \internal * \ingroup jkqtpplottersupprt */ -template<> -inline uint qHash(const QPair &key, uint seed ) noexcept(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) { +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +inline size_t qHash(const QPair &key, size_t seed=0) { +#else +inline uint qHash(const QPair &key, uint seed=0) { +#endif return static_cast(key.first)+static_cast(key.second); } @@ -1736,8 +1739,11 @@ inline uint qHash(const QPair &key, uint * \internal * \ingroup jkqtpplottersupprt */ -template<> -inline uint qHash(const Qt::MouseButton &key, uint /*seed*/ ) noexcept(noexcept(qHash(key))) { +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +inline size_t qHash(const Qt::MouseButton &key, size_t /*seed=0*/) { +#else +inline uint qHash(const Qt::MouseButton &key, uint /*seed=0*/) { +#endif return static_cast(key); } @@ -1745,8 +1751,11 @@ inline uint qHash(const Qt::MouseButton &key, uint /*seed*/ ) noexcept(noexcept( * \internal * \ingroup jkqtpplottersupprt */ -template<> -inline uint qHash(const Qt::KeyboardModifiers &key, uint /*seed*/ ) noexcept(noexcept(qHash(key))) { +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +inline size_t qHash(const Qt::KeyboardModifiers &key, size_t /*seed=0*/) { +#else +inline uint qHash(const Qt::KeyboardModifiers &key, uint /*seed=0*/) { +#endif return static_cast(key); }