Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:10:41+00:00 2026-06-02T10:10:41+00:00

In this page: http://qwt.sourceforge.net/class_qwt_plot_curve.html#afd13c94e23520dacbc37b4d0fd036a8b The method void QwtPlotCurve::setRawSamples() just saves the addresses of the

  • 0

In this page:

http://qwt.sourceforge.net/class_qwt_plot_curve.html#afd13c94e23520dacbc37b4d0fd036a8b

The method

void QwtPlotCurve::setRawSamples()

just saves the addresses of the data in the QwtPlotCurve, which is exactly what I want for efficiency.

While:

void QwtPlotCurve::setSamples()

uses QVector, which is more convenient. But it’s only “explicitly shared”. What does that mean? does save the pointer just like the first one?

I need to add a point to the plot each 50 ms. Deep-copying of data isn’t the best solution!!! advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:10:43+00:00Added an answer on June 2, 2026 at 10:10 am

    It’s juxtaposed against Qt’s concept of “implicit sharing”:

    http://doc.qt.io/archives/qt-4.7/implicit-sharing.html

    Even if you pass a QVector of data by value as a parameter in Qt, it will not copy the memory immediately. It will only make a copy if one of the vectors is changed.

    I would have thought that the documentation saying “explicit sharing” in the setSamples case is just to draw attention to the fact that you’re passing in QVectors by reference instead of by value:

    void QwtPlotCurve::setSamples(
        const QVector< double > &xData,
        const QVector< double > &yData 
    )
    

    And I also would have thought they did this so that if you change the data in your vector (or free it), it will affect the data held onto by the plot curve. You’d not expect that if you thought the vectors were passed by value (you can’t tell if you’re just reading the callsite).

    HOWEVER looking at the source code it appears that under the hood it’s just making an implicitly-shared copy anyway. In qwt_plot_curve.cpp we have:

    /*!
       \brief Initialize data with x- and y-arrays (explicitly shared)
    
       \param xData x data
       \param yData y data
       \sa QwtPointArrayData
    */
    void QwtPlotCurve::setSamples( const QVector<double> &xData,
        const QVector<double> &yData )
    {
        setData( new QwtPointArrayData( xData, yData ) );
    }
    

    We can see that QwtPointArrayData is declared in qwt_point_data.h like this:

    class QWT_EXPORT QwtPointArrayData: public QwtSeriesData<QPointF>
    {
    public:
        QwtPointArrayData( const QVector<double> &x, const QVector<double> &y );
        QwtPointArrayData( const double *x, const double *y, size_t size );
    
        virtual QRectF boundingRect() const;
    
        virtual size_t size() const;
        virtual QPointF sample( size_t i ) const;
        const QVector<double> &xData() const;
        const QVector<double> &yData() const;
    
    private:
        QVector<double> d_x;
        QVector<double> d_y;
    };
    

    The code for the constructor in qwt_point_data.cpp is just a simple assignment to d_x and d_y. Which goes back to plain ol’ implicit sharing. So changes you make in the data you passed in will not be seen by the plot; you will pay for the copy being made at the time of such a modification.

    If they were just going to do this, then why they bothered passing in a const reference (instead of just by value) is a mystery to me. The only “sharing” going on here seems to be implicit, so I don’t know what the “explicitly shared” comment is supposed to mean.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this page: http://losthobbit.net/temp/docking.html Here's the HTML: <html> <head> <title></title> </head> <body> <div style=position:
Consider this page @ http://www.bloodbone.ws/screwed.html I need to be able to have the a.grow
On this page: http://www.arvag.net/old/smsbox.de/ when you hover over Informationen and Über ins, it shows
On this page: http://www.anasiamusic.com/bio.html in the body text (Ana Sia's DJ crate is a
On this page: http://code.google.com/apis/accounts/docs/OAuth2UserAgent.html Google gives instructions for doing oauth with client side applications
in this page: http://www.studiokhalid.com/test/jquery/2.html I am trying to use a simple Jquery Coda slider
On this page: http://flowplayer.org/tools/tabs/slideshow.html Halfway down the page I find this code under the
This page says that GCC 4.5 has C++ raw string literals: http://gcc.gnu.org/projects/cxx0x.html But when
I read this page http://docs.composite.net/XSLT/XSLTFAQ?q=How+to+parse+an+XHTML+value+from+a+data+field+used+in+XSLT+functions%3f but I can not make it to work with
From this page (http://developer.apple.com/programs/ios/distribute.html) I've read this Custom B2B Apps You can also offer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.