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

QCustomPlot clear Data

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 12 Posters 18.2k 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.
  • RatzzR Offline
    RatzzR Offline
    Ratzz
    wrote on last edited by
    #2

    @HafsaElif

    Is it the same Question ?

    --Alles ist gut.

    1 Reply Last reply
    4
    • H Offline
      H Offline
      HafsaElif
      wrote on last edited by
      #3

      yes ı wrote.

      1 Reply Last reply
      0
      • RatzzR Offline
        RatzzR Offline
        Ratzz
        wrote on last edited by
        #4

        Is it solved?

        --Alles ist gut.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          HafsaElif
          wrote on last edited by
          #5

          no. all about deleting not cleaning

          kshegunovK mrjjM 2 Replies Last reply
          0
          • H HafsaElif

            no. all about deleting not cleaning

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on 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
            3
            • H HafsaElif

              no. all about deleting not cleaning

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on 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 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
                • kshegunovK kshegunov

                  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 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 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 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 last edited by mrjj
                        #12

                        Try ui->yourPlot->clearPlottables();

                        1 Reply Last reply
                        2
                        • D Offline
                          D Offline
                          david_808
                          wrote on last edited by
                          #13

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

                          mrjjM 1 Reply Last reply
                          0
                          • D david_808

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

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 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 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
                              • Joel BodenmannJ Offline
                                Joel BodenmannJ Offline
                                Joel Bodenmann
                                wrote on 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
                                6
                                • Joel BodenmannJ Joel Bodenmann

                                  @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 last edited by
                                  #17

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

                                  1 Reply Last reply
                                  0
                                  • Joel BodenmannJ Joel Bodenmann

                                    @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 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