Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Cannot include <QVector3D>
Forum Updated to NodeBB v4.3 + New Features

Cannot include <QVector3D>

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 900 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KRP1
    wrote on last edited by
    #1

    I am trying to pass a Qt.vector3d() from QML to c++. In my c++ class, as soon as I type in the

    #include <QVector3D>
    

    QtCreator shows the following error regardless of whether the .pro file has += gui

    qvector3d.h:57:20: error: redefinition of 'QVector3D'
    Test.h:1:1: note: in file included from ...\Testing\untitled20\Test.h:1:
    Test.h:5:10: note: in file included from ...\Testing\untitled20\Test.h:5:
    QVector3D:1:10: note: in file included from C:\Qt\Qt5.13.0\5.13.0\msvc2017_64\include\QtGui\QVector3D:1:
    qpoint.h:219:21: note: previous definition is here
    
    

    To Reproduce on my system

    I can reproduce this consistently. I am using Qt 5.13 on Windows.

    • Start with empty QtQuick application template.
    • Add a QObject derived class using the Add class wizard.
    • Add the include file for QVector3D.

    Test.h

    #ifndef TEST_H
    #define TEST_H
    
    #include <QObject>
    #include <QVector3D>
    
    
    class Test : public QObject
    {
        Q_OBJECT
    public:
        explicit Test(QObject *parent = nullptr);
    
    signals:
    
    public slots:
    };
    
    #endif // TEST_H
    
    

    Even if I start with a Qt Form application, I get the same error as soon as I include <QVector3D> in any source file. There is another declaration for QVector3D in the qpoint.h header that is being favored even though it only holds two elements, x and y.

    How can I get Qt.vector3d data when I can't even get a class with 3 elements to catch it? Why is this other mislabeled class taking over?

    Thanks for mulling this one over!

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #3

      You have a (modified) qpoint.h somewhere - the original qpoint.h does not defined a QVector3D class: https://code.woboq.org/qt5/qtbase/src/corelib/tools/qpoint.h.html

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      K 1 Reply Last reply
      1
      • K Offline
        K Offline
        KRP1
        wrote on last edited by
        #2

        UPDATE: If you don't include the header, the vector3d is passed from QML to C++ as the correct QVector3D. However, you can't access any of the correct methods for this version of QVector3D which in turn means you cannot extract the third component of the vector as only x and y are exposed in the qpoint.h version of QVector3D.

        The question remains,

        How does one access the correct signatures for QVector3D methods on the C++ side of a QML/C++ application?

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #3

          You have a (modified) qpoint.h somewhere - the original qpoint.h does not defined a QVector3D class: https://code.woboq.org/qt5/qtbase/src/corelib/tools/qpoint.h.html

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          K 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            You have a (modified) qpoint.h somewhere - the original qpoint.h does not defined a QVector3D class: https://code.woboq.org/qt5/qtbase/src/corelib/tools/qpoint.h.html

            K Offline
            K Offline
            KRP1
            wrote on last edited by
            #4

            @Christian-Ehrlicher
            Do you know of any automated Qt tools that would do this during compilation?

            I checked the install files, and a batch of them had been modified as of this morning when I first noticed the problem.

            <rant>The Qt installer on Windows is the worst. No option to fix the installation, and I have to upgrade the installer in order to be able to see any options that might remotely be like "fix installation". And as far as I can tell you can't do anything with it if you are not connected to the network.</rant>

            On the non-rant side, the Qt/QML framework is hands down my favorite for C++ applications.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved