Problems with Open-Source Downloads read and

Using Q3DBars - getting linker errors

  • I'm trying to follow the example given here showing how to use Q3DBars. I've been able to compile, link, and run AudioLevels Example which uses Q3DBars without error.

    When I try creating my own application to initialize a Q3DBars object, I get linker errors saying that it is unable to find a reference to QtDataVisualization::Q3DBars::Q3DBars(QSurfaceFormat const*, QWindow*).

    Here is my code, which is based off the example for Q3DBars from the documentation:

    #include <QGuiApplication>
    #include <QtDataVisualization/Q3DBars>
    using namespace QtDataVisualization;
    int main(int argc, char *argv[])
        QGuiApplication a(argc, argv);
        Q3DBars b;
        return a.exec();

    Here is my .pro file:

    # Project created by QtCreator 2018-11-19T11:59:09
    QT       += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = testtest
    TEMPLATE = app
    CONFIG += c++11
    SOURCES += \
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target

    Ultimately I was going to replace the data given in the example with my own data and wrap the implementation in its own class for ease of use, but I can't even instantiate a Q3DBars object because I am unable to get my code to link. What am I missing that prevents the linker from finding the definitions for Q3DBars? I've tried compiling on both Windows 10/Linux using VS2017 and gcc 7.3.0, Qt version 5.9. I've also tried cleaning and deleting my build directories, re-running qmake but had no success.

  • Also, I've tried comparing my project to the AudioLevels example to identify any differences that may cause the linker error, but I have been unable to identify a cause so far.

  • I figured out my problem. I looked at the examples.pri file and discovered that I needed to include:

    QT += datavisualization

    in the .pro file. IDK how to tell from the documentation that this was needed, but I have been able to proceed.

  • Lifetime Qt Champion

Log in to reply