Qt World Summit: Register Today!

Use Qt Data Visualization with Visual Studio 2015

  • Hi Guys,

    I have some Problems using Qt Data visualization with Visual Studio 2015.
    I installed Qt Data Visualization at the Installation of Qt.

    1. Problem:
      In Qt Creator i include the
      #include <QtDataVisualization> and everything worked fine
      But in Visual Studio there is no such Lib.
      There is only the Folder
      #include <QtDataVisualization> with headers like :
      #include <QtDataVisualization\qtdatavisualizationversion.h> or
      #include <QtDataVisualization\q3dbars.h>

    so i'm not really sure which header File i need.

    1. Problem :

    So first i wanted to create only the dialog with Qt Data Visualization and without any Diagram so i used :

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

    in the main Function.
    But nothing happens (1.Problem).
    Did I forget sth ?
    In the Tutorial they say i should add this in the .pro File :
    QT += datavisualization
    But in Visual Studio there is no .pro FIle... do I have to add sth else ?

    I hope that sb can Help me.

    Thanks !

  • Lifetime Qt Champion

  • Yes I installed the plugin for 2015. Do i have to create a .pro File and insert the line : QT += datavisualization ?

  • Lifetime Qt Champion

    Well that is needed normally.
    You should have a .pro file already ?

  • If I start a Qt Project with VIsual Studio there is no .pro File. I created a .pro File wiith the Qt Add on and added the line : QT += datavisualization

    This is my Code :

    #include <QtDataVisualization\q3dbars.h>

    using namespace QtDataVisualization;

    int main(int argc, char *argv[])
    QApplication a(argc, argv);
    Q3DBars *graph = new Q3DBars();
    newtest w;
    return a.exec();

    and then i get a lot of Link errors ... see Picture

  • Lifetime Qt Champion

    Did you make sure to run qmake on the .pro file?
    Sorry , I have not use VS with the qt plugin so not sure why it just dont work.
    It seems not to link it in.

    Could you try with Creator so we know QtDataVisualization is installed and working and its just a VS issue ?

  • With the Qt Creator every thing works. Now I imported the Qt lib with the Properties of the Project and i don't get any Errors when i build my Project.

    But when I start my Project nothing happens :/

    see Picture:
    The Problem are caused by the Lines:

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

    The Code works perfectly on Qt Creator


  • Lifetime Qt Champion

    Why do u need QWidget::createWindowContainer() ?
    Is this QML ?
    Anyway, same code should work both in VS and Creator.
    Did you use the VS compiler in Creator?

  • I'm not sure about the QWidget ... i took a QtDataVisualization example ...and copied it..because i works in qtcreator.

    Yes iam usin the VS compiler in the Creator

    Microsoft visual c++ compiler 14

Log in to reply