i am downloaded QCustomPlot v2.1.1 and i am using Qt 6.10.1. once i added qcustomplot.cpp/.h into my project i get warnings for deprecated code and also an error that qcustomplot.cpp is too big.
need help to fix it
i am downloaded QCustomPlot v2.1.1 and i am using Qt 6.10.1. once i added qcustomplot.cpp/.h into my project i get warnings for deprecated code and also an error that qcustomplot.cpp is too big.
need help to fix it
# if cmake:
cmake_minimum_required(VERSION 3.16)
project(ceshi3 VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-Wa,-mbig-obj)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets PrintSupport)
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
qcustomplot.h
qcustomplot.cpp
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(ceshi3
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
else()
if(ANDROID)
add_library(ceshi3 SHARED
${PROJECT_SOURCES}
)
else()
add_executable(ceshi3
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(ceshi3 PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::PrintSupport)
target_include_directories(ceshi3 PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
if(${QT_VERSION} VERSION_LESS 6.1.0)
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.ceshi3)
endif()
set_target_properties(ceshi3 PROPERTIES
${BUNDLE_ID_OPTION}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
include(GNUInstallDirs)
install(TARGETS ceshi3
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(ceshi3)
endif()
###############################################
# if qmake:
QT += core gui printsupport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
CONFIG += c++17
SOURCES += \
main.cpp \
mainwindow.cpp \
qcustomplot.cpp
HEADERS += \
mainwindow.h \
qcustomplot.h
FORMS += \
mainwindow.ui
QMAKE_CXXFLAGS += -Wa,-mbig-obj
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
Deprecated does mean, its still working, but might stop with future Qt releases. As Qt gives you the information about how to fix the warnings, its not impossible to do.
What is the "too big" error about?
Oliver
I think I had to same issue in my project.
I added following code my CMake file
if (MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj")
endif()
For compatibility with newer Qt, I noticed that the Wireshark project regularly updates their QCustomPlot files.
https://gitlab.com/wireshark/wireshark/-/commits/master/ui/qt/widgets/qcustomplot.cpp