Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to write the data from QTVector 3D into 3 Arrays (Qbytearray x; Qbytearray y;Qbytearray z;)
Forum Updated to NodeBB v4.3 + New Features

How to write the data from QTVector 3D into 3 Arrays (Qbytearray x; Qbytearray y;Qbytearray z;)

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 531 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.
  • M Offline
    M Offline
    Markus Ippy
    wrote on last edited by
    #1

    Good day

    I am having a problem understanding QTVector3D .
    Below is a snipped from the QTLabs Sensehat module for Raspberry Pi. The example works perfectly .
    I would like to send the data via Serial or UDP and therefore would like to Write the x,y,z values from QVector3D into 3 Arrays so i can send them. My problem is i don't know how i can split "v" into 3 arrays ?

    Qbytearray X;
    Qbytearray Y;
    Qbytearray Z;

    myarray.append(v); does obviously not work

    How would i do that ? I could not

    QObject::connect(&sensors, &QSenseHatSensors::gyroChanged, [](const QVector3D &v) {
        qDebug() << "Gyro:" << v;
    });
    

    Hope someone can help me

    jsulmJ 1 Reply Last reply
    0
    • M Markus Ippy

      Good day

      I am having a problem understanding QTVector3D .
      Below is a snipped from the QTLabs Sensehat module for Raspberry Pi. The example works perfectly .
      I would like to send the data via Serial or UDP and therefore would like to Write the x,y,z values from QVector3D into 3 Arrays so i can send them. My problem is i don't know how i can split "v" into 3 arrays ?

      Qbytearray X;
      Qbytearray Y;
      Qbytearray Z;

      myarray.append(v); does obviously not work

      How would i do that ? I could not

      QObject::connect(&sensors, &QSenseHatSensors::gyroChanged, [](const QVector3D &v) {
          qDebug() << "Gyro:" << v;
      });
      

      Hope someone can help me

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @Markus-Ippy

      QDataStream xStream(&X, QIODevice::WriteOnly);
      xStream << v.x();
      

      Same for Y and Z.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4

      • Login

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