2

I'm trying to create a simple qt application in visual studio, I also made sure to install all qt components.

Code:

#include "QtWidgetsApplication2.h"
#include <QtWidgets/QApplication>

#include <QtDataVisualization/Q3DSurface>
#include <QtDataVisualization/QSurfaceDataProxy>
#include <QtDataVisualization/QHeightMapSurfaceDataProxy>
#include <QtDataVisualization/QSurface3DSeries>
#include <QtWidgets/QSlider>


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QtWidgetsApplication2 w;

    Q3DSurface* graph = new Q3DSurface();
    QWidget* container = QWidget::createWindowContainer(graph);

    w.show();
    return a.exec();
}

I have already set the correct QT version, and the path to the aditional libraries for the linker(at C:\Qt\6.4.0\msvc2019_64\lib) but somehow i'm still getting an error linker LNK2019. What gives?

EDIT:

my .pro file:

TEMPLATE = app
TARGET = QtWidgetsApplication2
DESTDIR = ../x64/Debug
CONFIG += debug
DEPENDPATH += .
MOC_DIR += .
OBJECTS_DIR += debug
UI_DIR += .
RCC_DIR += .
include(QtWidgetsApplication2.pri)
drescherjm
  • 10,365
  • 5
  • 44
  • 64
Slava
  • 73
  • 5
  • 1
    Where do you tell it to actually link anything? – ChrisMM Oct 26 '22 at 17:45
  • 1
    Looks like you are not using CMake. Looks like you are using QMake or qt-creator or the visual studio addon with a .pro – drescherjm Oct 26 '22 at 17:45
  • 2
    `Q3DSurface` from the documentation: [https://doc.qt.io/qt-6/q3dsurface.html](https://doc.qt.io/qt-6/q3dsurface.html) should require `QT += datavisualization` added to your `.pro` – drescherjm Oct 26 '22 at 17:48
  • @ChrisMM I created a simple widget application (provided by visual studio after you install QT tools) which compiled fine, but as soon as added QtDataVisualization I started to get this error. As for your question , like I said, I went to project Settings->Linker->Aditional Libraries and copied the path to QT's lib files – Slava Oct 26 '22 at 17:49
  • 1
    You should not modify your `Linker->Aditional Dependecies` at all when using CMake or QMake (which you seem to be using) – drescherjm Oct 26 '22 at 17:49
  • @ChrisMM yeah I didn't tell it to link, since the first example worked, I thought vstools did everything automatically – Slava Oct 26 '22 at 18:38
  • You setup the linking in your `.pro`. The Qt documentation will tell you the qmake command which is what you need to add to link to use the class. – drescherjm Oct 26 '22 at 18:54

1 Answers1

1

From the Qt documentation for Q3DSurface here: https://doc.qt.io/qt-6/q3dsurface.html on the qmake line at the top it has qmake: QT += datavisualization the QT += datavisualization part is what you need to add to your .pro file to use the Q3DSurface class. This will setup the linking and any additional include directories.

drescherjm
  • 10,365
  • 5
  • 44
  • 64