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. make a curve
QtWS25 Last Chance

make a curve

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 5 Posters 1.3k 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.
  • J Offline
    J Offline
    julie546
    wrote on last edited by
    #1

    I would like to make a curve giving each time the values ​​of x and y, I did a search on the internet but I did not find anything important you find attached my code

    for (int i=0; i< scan.npoints; i++)
    {
    x=scan.points[i].rangecos(scan.points[i].angle);
    y=scan.points[i].range
    sin(scan.points[i].angle);
    }

    JonBJ 1 Reply Last reply
    0
    • J julie546

      I would like to make a curve giving each time the values ​​of x and y, I did a search on the internet but I did not find anything important you find attached my code

      for (int i=0; i< scan.npoints; i++)
      {
      x=scan.points[i].rangecos(scan.points[i].angle);
      y=scan.points[i].range
      sin(scan.points[i].angle);
      }

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @julie546
      I presume you are supposed to use QSplineSeries Class on a QChart?

      J 1 Reply Last reply
      1
      • JonBJ JonB

        @julie546
        I presume you are supposed to use QSplineSeries Class on a QChart?

        J Offline
        J Offline
        julie546
        wrote on last edited by
        #3

        @JonB thank you for your answer I did a search on this library but when I had it added
        #include <QSplineSeries>
        there is an error: QSplineSeries file not found

        jsulmJ 1 Reply Last reply
        0
        • J julie546

          @JonB thank you for your answer I did a search on this library but when I had it added
          #include <QSplineSeries>
          there is an error: QSplineSeries file not found

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

          @julie546 Well, you need https://doc.qt.io/qt-5/qtcharts-index.html and do what is shown in that link

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

          J 1 Reply Last reply
          0
          • jsulmJ jsulm

            @julie546 Well, you need https://doc.qt.io/qt-5/qtcharts-index.html and do what is shown in that link

            J Offline
            J Offline
            julie546
            wrote on last edited by
            #5

            @jsulm thanks but i have is error Project ERROR: Unknown module(s) in QT: charts

            jsulmJ J.HilkJ 2 Replies Last reply
            0
            • J julie546

              @jsulm thanks but i have is error Project ERROR: Unknown module(s) in QT: charts

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

              @julie546 Because you need to install QtCharts separately, it is not part of normal Qt installation. Start Qt Maintenance Tool and select QtCharts there.

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

              1 Reply Last reply
              1
              • J julie546

                @jsulm thanks but i have is error Project ERROR: Unknown module(s) in QT: charts

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @julie546 after the installation you have to add it to the project files as additional module
                QT += charts


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                J 1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @julie546 after the installation you have to add it to the project files as additional module
                  QT += charts

                  J Offline
                  J Offline
                  julie546
                  wrote on last edited by
                  #8

                  @J-Hilk @jsulm
                  I installed this library using "sudo apt install libqt5charts5-dev"
                  and i added QT += charts on(.pro)
                  on the .cpp
                  i added #include<QSplineSeries> the QT was able to identify it
                  but when i added QSplineSeries *series = new QSplineSeries();
                  i have this error : unknown type name QSplineSeries
                  i'm following this exemple https://doc.qt.io/qt-5/qtcharts-splinechart-example.html

                  jsulmJ 1 Reply Last reply
                  0
                  • J julie546

                    @J-Hilk @jsulm
                    I installed this library using "sudo apt install libqt5charts5-dev"
                    and i added QT += charts on(.pro)
                    on the .cpp
                    i added #include<QSplineSeries> the QT was able to identify it
                    but when i added QSplineSeries *series = new QSplineSeries();
                    i have this error : unknown type name QSplineSeries
                    i'm following this exemple https://doc.qt.io/qt-5/qtcharts-splinechart-example.html

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

                    @julie546 said in make a curve:

                    I installed this library using "sudo apt install libqt5charts5-dev"

                    And you're also using Qt installed via apt?
                    Please show the code where you get the error.
                    And don't forget: after changing pro file always do a clean rebuild.

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

                    J 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @julie546 said in make a curve:

                      I installed this library using "sudo apt install libqt5charts5-dev"

                      And you're also using Qt installed via apt?
                      Please show the code where you get the error.
                      And don't forget: after changing pro file always do a clean rebuild.

                      J Offline
                      J Offline
                      julie546
                      wrote on last edited by
                      #10

                      @jsulm I found this forum he recommended to use "sudo apt install libqt5charts5-dev"
                      https://forum.qt.io/topic/120196/qtcharts-installation-on-ubuntu/3
                      for the code i only did
                      #include<QSplineSeries>
                      {
                      ui->setupUi(this);

                      QSplineSeries *series = new QSplineSeries();
                      series->setName("spline");
                      

                      like this exemple https://doc.qt.io/qt-5/qtcharts-splinechart-example.html
                      i only wanna make a graph for the x and the y
                      for (int i=0; i< scan.npoints; i++)
                      {
                      x=scan.points[i].rangecos(scan.points[i].angle);
                      y=scan.points[i].rangesin(scan.points[i].angle);
                      }
                      Inkedtéléchargement_LI.jpg

                      jsulmJ 1 Reply Last reply
                      0
                      • J julie546

                        @jsulm I found this forum he recommended to use "sudo apt install libqt5charts5-dev"
                        https://forum.qt.io/topic/120196/qtcharts-installation-on-ubuntu/3
                        for the code i only did
                        #include<QSplineSeries>
                        {
                        ui->setupUi(this);

                        QSplineSeries *series = new QSplineSeries();
                        series->setName("spline");
                        

                        like this exemple https://doc.qt.io/qt-5/qtcharts-splinechart-example.html
                        i only wanna make a graph for the x and the y
                        for (int i=0; i< scan.npoints; i++)
                        {
                        x=scan.points[i].rangecos(scan.points[i].angle);
                        y=scan.points[i].rangesin(scan.points[i].angle);
                        }
                        Inkedtéléchargement_LI.jpg

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

                        @julie546 You need to install QtCharts for Qt you are using. So, how did you install Qt? Did you install it using apt? Did you install it using Qt installer?

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

                        J 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @julie546 You need to install QtCharts for Qt you are using. So, how did you install Qt? Did you install it using apt? Did you install it using Qt installer?

                          J Offline
                          J Offline
                          julie546
                          wrote on last edited by
                          #12

                          @jsulm for the installation i did that :
                          $ sudo rpi-update
                          $ sudo reboot
                          $ sudo apt-get update
                          $ sudo apt-get upgrade
                          $ sudo apt-get install qt5-default
                          $ sudo apt-get install qtcreator
                          $ sudo apt-get install build-essential
                          $ sudo apt-get install libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libudev-dev libinput-dev libxkbcommon-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libraspberrypi-dev
                          sudo apt-get install -y build-essential libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libudev-dev libinput-dev libxkbcommon-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libraspberrypi-dev
                          sudo apt-get install -y bluez libbluetooth-dev
                          sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad libgstreamer-plugins-bad1.0-dev gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-alsa
                          sudo apt-get install -y libasound2-dev pulseaudio libpulse-dev
                          sudo apt-get install -y libsqlite3-dev libpq-dev libmariadbclient-dev libmariadbclient-dev-compat
                          sudo apt-get install -y libcups2-dev
                          sudo apt-get install -y libx11-dev libxcb1-dev libxkbcommon-x11-dev libx11-xcb-dev libxext-dev
                          sudo apt-get install -y libatspi-dev
                          sudo apt-get install -y libwayland-dev

                          so yes i used the apt

                          jsulmJ 1 Reply Last reply
                          0
                          • J julie546

                            @jsulm for the installation i did that :
                            $ sudo rpi-update
                            $ sudo reboot
                            $ sudo apt-get update
                            $ sudo apt-get upgrade
                            $ sudo apt-get install qt5-default
                            $ sudo apt-get install qtcreator
                            $ sudo apt-get install build-essential
                            $ sudo apt-get install libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libudev-dev libinput-dev libxkbcommon-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libraspberrypi-dev
                            sudo apt-get install -y build-essential libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libudev-dev libinput-dev libxkbcommon-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libraspberrypi-dev
                            sudo apt-get install -y bluez libbluetooth-dev
                            sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad libgstreamer-plugins-bad1.0-dev gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-alsa
                            sudo apt-get install -y libasound2-dev pulseaudio libpulse-dev
                            sudo apt-get install -y libsqlite3-dev libpq-dev libmariadbclient-dev libmariadbclient-dev-compat
                            sudo apt-get install -y libcups2-dev
                            sudo apt-get install -y libx11-dev libxcb1-dev libxkbcommon-x11-dev libx11-xcb-dev libxext-dev
                            sudo apt-get install -y libatspi-dev
                            sudo apt-get install -y libwayland-dev

                            so yes i used the apt

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

                            @julie546 So, you are developing for RPi? Why not mention that from the beginning?
                            Do you cross compile? Or do you build directly on RPi?
                            And you called "sudo apt install libqt5charts5-dev" also on RPi?

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

                            J 2 Replies Last reply
                            0
                            • jsulmJ jsulm

                              @julie546 So, you are developing for RPi? Why not mention that from the beginning?
                              Do you cross compile? Or do you build directly on RPi?
                              And you called "sudo apt install libqt5charts5-dev" also on RPi?

                              J Offline
                              J Offline
                              julie546
                              wrote on last edited by julie546
                              #14

                              @jsulm yes i m working with RaspberryPi 4
                              yes i'm calling "sudo apt install libqt5charts5-dev" on RPi
                              all my work is on Rpi4

                              1 Reply Last reply
                              0
                              • jsulmJ jsulm

                                @julie546 So, you are developing for RPi? Why not mention that from the beginning?
                                Do you cross compile? Or do you build directly on RPi?
                                And you called "sudo apt install libqt5charts5-dev" also on RPi?

                                J Offline
                                J Offline
                                julie546
                                wrote on last edited by
                                #15

                                @jsulm theres any probleme with RPi ?

                                jsulmJ 1 Reply Last reply
                                0
                                • J julie546

                                  @jsulm theres any probleme with RPi ?

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

                                  @julie546 Did you do a clean rebuild of your app (delete build folder, run qmake and build)?

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

                                  J 1 Reply Last reply
                                  0
                                  • jsulmJ jsulm

                                    @julie546 Did you do a clean rebuild of your app (delete build folder, run qmake and build)?

                                    J Offline
                                    J Offline
                                    julie546
                                    wrote on last edited by
                                    #17

                                    @jsulm I solved this problem using #include <QtCharts>
                                    using namespace QtCharts;
                                    and I did this code but I couldn't make the graph
                                    {
                                    ui->setupUi(this);

                                    QSplineSeries *series = new QSplineSeries();
                                    series->setName("spline");
                                    

                                    .
                                    .
                                    .
                                    .
                                    .
                                    }
                                    void Lidar1(QSplineSeries *series)
                                    {
                                    .
                                    .
                                    .
                                    .
                                    for (int i=0; i< scan.npoints; i++)
                                    {
                                    x=scan.points[i].rangecos(scan.points[i].angle);
                                    y=scan.points[i].rangesin(scan.points[i].angle);
                                    series->append(x, y);

                                    }
                                    }

                                    mrjjM 1 Reply Last reply
                                    0
                                    • J julie546

                                      @jsulm I solved this problem using #include <QtCharts>
                                      using namespace QtCharts;
                                      and I did this code but I couldn't make the graph
                                      {
                                      ui->setupUi(this);

                                      QSplineSeries *series = new QSplineSeries();
                                      series->setName("spline");
                                      

                                      .
                                      .
                                      .
                                      .
                                      .
                                      }
                                      void Lidar1(QSplineSeries *series)
                                      {
                                      .
                                      .
                                      .
                                      .
                                      for (int i=0; i< scan.npoints; i++)
                                      {
                                      x=scan.points[i].rangecos(scan.points[i].angle);
                                      y=scan.points[i].rangesin(scan.points[i].angle);
                                      series->append(x, y);

                                      }
                                      }

                                      mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      Hi
                                      after you put points in the Series
                                      you need to call
                                      chart->addSeries(series);

                                      chart being an instance of QChart

                                      like they do here
                                      https://doc.qt.io/qt-5/qtcharts-linechart-example.html

                                      1 Reply Last reply
                                      1

                                      • Login

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