Issue with QtCharts in Qt6.1.1
-
Greetings,
I was successfully using QtCharts with an application with Qt 5.15.2. I recently installed Qt 6.1.1 using the online installer on my Macbook Pro running MacOS 11.4. In both cases I use CMake as the build system. Now when I try to compile the application with Qt 6.1.1 I get an error from the generated ui header files that "'QtCharts/chartsnamespace.h' file not found". Looking at the various ui_.h files there is a line "#include <QtCharts/chartsnamespace.h>". I can find the chartsnamespace.h file in the 5.15.2 src directory, but nowhere in the 6.1.1 folder structure. Thinking that the ui_.h files needed to be regnerated, I manually deleted them and made sure that they were recreated during the build process, but the issue remains. Thanks in advance for any insight or advice you might have. -
Hi,
The charts module is not part of Qt 6.1.
In between you can build it yourself manually.
-
Greetings,
Yes, I downloaded the additional package using the maintenance tool, and performed the build and install. I can see the framework in the expected location, as well, so I think everything is ok there. I also tried the same procedure with the 6.2.0 preview and got the same result. -
How did you build/install the module ?
-
Do you have any cmake file in these sources ?
I suspect it's Qt 5 sources rather than the dev which is for Qt 6. -
What result do you get if you use cmake to build the module rather than qmake ?
-
Hi,
Building with CMake gives the following error...cmake .
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- The C compiler identification is AppleClang 12.0.5.12050022
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:16 (find_package):
Could not find a package configuration file provided by "Qt6" (requested
version 6.1.1) with any of the following names:Qt6Config.cmake qt6-config.cmake
Add the installation prefix of "Qt6" to CMAKE_PREFIX_PATH or set "Qt6_DIR"
to a directory containing one of the above files. If "Qt6" provides a
separate development package or SDK, be sure it has been installed.-- Configuring incomplete, errors occurred!
See also "/Users/ryan/Qt/6.1.1/Src/qtcharts/CMakeFiles/CMakeOutput.log".
See also "/Users/ryan/Qt/6.1.1/Src/qtcharts/CMakeFiles/CMakeError.log". -
Don't build directly in the root of your sources. You should at least create a build folder and run cmake from there.
As for the error, pass the CMAKE_PREFIX_PATH pointing to where your Qt 6 cmake files are located.
-
Hello again,
I'm not terribly experienced in using CMake, so this is what I did, but unfortunately there are more errors:mkdir build
❯ build
❯ cmake -D CMAKE_PREFIX_PATH="~/Qt/6.1.1/clang_64/lib/cmake/Qt6" ..
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
CMake Warning at /Users/ryan/Qt/6.1.1/clang_64/lib/cmake/Qt6/Qt6Config.cmake:97 (find_package):
Found package configuration file:/Users/ryan/Qt/6.1.1/clang_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
NOT FOUND.
Call Stack (most recent call first):
CMakeLists.txt:16 (find_package)CMake Error at CMakeLists.txt:16 (find_package):
Found package configuration file:/Users/ryan/Qt/6.1.1/clang_64/lib/cmake/Qt6/Qt6Config.cmake
but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
FOUND. Reason given by package:Failed to find Qt component "Core" config file at ""
-- Configuring incomplete, errors occurred!
See also "/Users/ryan/Qt/6.1.1/Src/qtcharts/CMakeFiles/CMakeOutput.log".
See also "/Users/ryan/Qt/6.1.1/Src/qtcharts/CMakeFiles/CMakeError.log". -
I used cmake-gui, as suggested and manually set the Qt6*_DIR variables to the appropriate values (otherwise errors are produced as the directories aren't identified). The build process completes and installs properly, but I get the same errors when trying to compile my application.
I tried compiling an example that uses QtCharts (datetimeaxis), and that works. I do have some forms that use a QChartView widget. Since the errors are popping up in the generated ui_*.h files, do you think that this is somehow related?
-
How did you put the charts through designer ?
Using promotion ? -
Great !
Thanks for the feedback.
Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :-)