Important: Please read the Qt Code of Conduct -

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.

  • Lifetime Qt Champion


    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.

  • Lifetime Qt Champion

    How did you build/install the module ?

  • Hi,
    I follow the instructions in the README located in ~/Qt/6.1.1/Src/qtcharts:

    ~/Qt/6.1.1/clang_64/bin/qmake CONFIG+="debug_and_release build_all"
    make install

  • Lifetime Qt Champion

    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.

  • There is at least a CMakeLists.txt file in the Qt/6.1.1/Src/qtcharts directory.

  • Lifetime Qt Champion

    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
    -- The C compiler identification is AppleClang
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /Applications/ - 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/ - 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:


    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".

  • Lifetime Qt Champion

    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:


    but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
    Call Stack (most recent call first):
    CMakeLists.txt:16 (find_package)

    CMake Error at CMakeLists.txt:16 (find_package):
    Found package configuration file:


    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".

  • use cmake-gui and you can easily find and solve problems

  • 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?

  • Lifetime Qt Champion

    How did you put the charts through designer ?
    Using promotion ?

  • I believe's been a while since I touched the forms, but that rings a bell. Maybe I need to delete it and try the same process in case there's some legacy code still lurking in the background.

  • When I use the "promote" option in Designer I can now see where the reference to chartsnamespace.h is coming from (see attachment).

    Screen Shot 2021-06-15 at 5.32.36 PM.png

  • Ok, solved! I had to reset the the promotion values as described here. I'm attaching a screenshot for reference in case anyone else runs into the same problem.Screen Shot 2021-06-16 at 8.24.18 AM.png

  • Lifetime Qt Champion

    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 :-)

  • @SGaist Done. Thanks for you help!

Log in to reply