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. QCustomPlot clear Data
Forum Updated to NodeBB v4.3 + New Features

QCustomPlot clear Data

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 12 Posters 16.7k Views 4 Watching
  • 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.
  • H Offline
    H Offline
    HafsaElif
    wrote on 2 Feb 2017, 07:06 last edited by
    #5

    no. all about deleting not cleaning

    K M 2 Replies Last reply 2 Feb 2017, 10:24
    0
    • H HafsaElif
      2 Feb 2017, 07:06

      no. all about deleting not cleaning

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 2 Feb 2017, 10:24 last edited by
      #6

      I think Ian explained rather clearly what you can or can not do. I don't see how we could add to that.

      Read and abide by the Qt Code of Conduct

      H 1 Reply Last reply 2 Feb 2017, 12:40
      3
      • H HafsaElif
        2 Feb 2017, 07:06

        no. all about deleting not cleaning

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 2 Feb 2017, 10:36 last edited by
        #7

        @HafsaElif
        There is
        graph->data()->clear();
        Since the 2.0 beta version.

        Alternatively, you can simply give it an empty data list.
        Then its "Clear".

        1 Reply Last reply
        4
        • H Offline
          H Offline
          HafsaElif
          wrote on 2 Feb 2017, 12:37 last edited by
          #8

          I wrote this code and problem solved. Thank you mrjj !!!

          ui->qcustom->graph(0)->data()->clear();
          ui->qcustom->graph(1)->data()->clear();
          ui->qcustom->graph(2)->data()->clear();
          ui->qcustom->replot();
          

          0_1486038990528_Screenshot from 2017-02-01 12:00:06.png 0_1486038992133_Screenshot from 2017-02-02 15:35:37.png

          1 Reply Last reply
          1
          • K kshegunov
            2 Feb 2017, 10:24

            I think Ian explained rather clearly what you can or can not do. I don't see how we could add to that.

            H Offline
            H Offline
            HafsaElif
            wrote on 2 Feb 2017, 12:40 last edited by
            #9

            @kshegunov I dont want to set empty data . I was searching for fallowing code which is shared by mrjj.

            1 Reply Last reply
            0
            • I Offline
              I Offline
              indu
              wrote on 2 Mar 2017, 09:01 last edited by
              #10

              Hi,

              I'm facing some issue with ui->qcustom->graph(0)->data()->clear();. It is not working for me.
              Data container is not getting cleared, even if i call clear() and then replot().
              Pls help.
              Thank you.

              1 Reply Last reply
              0
              • O Offline
                O Offline
                oaeide
                wrote on 22 Jun 2017, 21:17 last edited by
                #11

                I have the same problem as indu2. Calling clear() and replot(), nothing happens

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Marcel92
                  wrote on 26 Jun 2017, 19:47 last edited by mrjj
                  #12

                  Try ui->yourPlot->clearPlottables();

                  1 Reply Last reply
                  2
                  • D Offline
                    D Offline
                    david_808
                    wrote on 9 Oct 2017, 13:44 last edited by
                    #13

                    clearPlottables() does not work because it deletes the object entirely.

                    M 1 Reply Last reply 9 Oct 2017, 13:52
                    0
                    • D david_808
                      9 Oct 2017, 13:44

                      clearPlottables() does not work because it deletes the object entirely.

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 9 Oct 2017, 13:52 last edited by
                      #14

                      @david_808

                      Hi
                      Maybe ask the author of customplot about how to do it correctly then?

                      1 Reply Last reply
                      1
                      • S Offline
                        S Offline
                        Scarab
                        wrote on 5 Dec 2017, 13:31 last edited by
                        #15

                        Try:

                        for( int g=0; g<pq_plot->graphCount(); g++ )
                        {
                            pq_plot->graph(g)->data().data().clear();
                        }
                        pq_plot->replot();
                        

                        don't know why to use ->data().data() but it works for me.

                        1 Reply Last reply
                        1
                        • J Offline
                          J Offline
                          Joel Bodenmann
                          wrote on 25 Dec 2019, 16:46 last edited by
                          #16

                          @Scarab said in QCustomPlot clear Data:

                          don't know why to use ->data().data() but it works for me.

                          The type returned by QCPGraph::data() is a shared pointer to the data container. Both the shared pointer as well as the object the shared pointer is pointing to have a clear() function:

                          • If you do pq_plot->graph(g)->data().clear() you are calling QSharedPointer::clear().
                          • If you do pq_plot->graph(g)->data()->clear() you're calling QCPGraphDataContainer::clear() - which is what you actually want.

                          Calling pq_plot->graph(g)->data().data().clear() (as per your example) effectively calls QCPGraphDataContainer::clear() because QSharedPointer::data() returns the raw pointer managed by the shared pointer.
                          Therefore, pq_plot->graph(g)->data().data().clear() and pq_plot->graph(g)->data()->clear() are equivalent.

                          I hope this helps to prevent confusion for people that come across this in the future.

                          Industrial process automation software: https://simulton.com
                          Embedded Graphics & GUI library: https://ugfx.io

                          JamshidJ Q 2 Replies Last reply 26 Dec 2019, 06:07
                          6
                          • J Joel Bodenmann
                            25 Dec 2019, 16:46

                            @Scarab said in QCustomPlot clear Data:

                            don't know why to use ->data().data() but it works for me.

                            The type returned by QCPGraph::data() is a shared pointer to the data container. Both the shared pointer as well as the object the shared pointer is pointing to have a clear() function:

                            • If you do pq_plot->graph(g)->data().clear() you are calling QSharedPointer::clear().
                            • If you do pq_plot->graph(g)->data()->clear() you're calling QCPGraphDataContainer::clear() - which is what you actually want.

                            Calling pq_plot->graph(g)->data().data().clear() (as per your example) effectively calls QCPGraphDataContainer::clear() because QSharedPointer::data() returns the raw pointer managed by the shared pointer.
                            Therefore, pq_plot->graph(g)->data().data().clear() and pq_plot->graph(g)->data()->clear() are equivalent.

                            I hope this helps to prevent confusion for people that come across this in the future.

                            JamshidJ Offline
                            JamshidJ Offline
                            Jamshid
                            wrote on 26 Dec 2019, 06:07 last edited by
                            #17

                            @Joel-Bodenmann It was so helpful for me, thanks.

                            1 Reply Last reply
                            0
                            • J Joel Bodenmann
                              25 Dec 2019, 16:46

                              @Scarab said in QCustomPlot clear Data:

                              don't know why to use ->data().data() but it works for me.

                              The type returned by QCPGraph::data() is a shared pointer to the data container. Both the shared pointer as well as the object the shared pointer is pointing to have a clear() function:

                              • If you do pq_plot->graph(g)->data().clear() you are calling QSharedPointer::clear().
                              • If you do pq_plot->graph(g)->data()->clear() you're calling QCPGraphDataContainer::clear() - which is what you actually want.

                              Calling pq_plot->graph(g)->data().data().clear() (as per your example) effectively calls QCPGraphDataContainer::clear() because QSharedPointer::data() returns the raw pointer managed by the shared pointer.
                              Therefore, pq_plot->graph(g)->data().data().clear() and pq_plot->graph(g)->data()->clear() are equivalent.

                              I hope this helps to prevent confusion for people that come across this in the future.

                              Q Offline
                              Q Offline
                              QtTester
                              wrote on 12 Feb 2021, 02:54 last edited by
                              #18

                              @Joel-Bodenmann said in QCustomPlot clear Data:

                              iner::clear()
                              I have tested for one hour, the memory grow from 8192k to 9600k,when i call clear(),the memory is still 9600k, seems not release.

                              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