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 7930405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:24:41+00:00 2026-06-03T20:24:41+00:00

I would like to make a QList of QwtPlotCurve s. The reason for this

  • 0

I would like to make a QList of QwtPlotCurve s. The reason for this is to be able to remove them later form my QwtPlot.
I have the following code:

QList<QwtPlotCurve> myList = new QList<QwtPlotCurve>;
QwtPlotCurve* curve1 = new QwtPlotCurve();
QwtPlotCurve* curve2 = new QwtPlotCurve();
curves->append(curve1);
curves->append(curve2);

The code doesn’t compile and the compiler outputs:

error: conversion from ‘QList‘ to non-scalar type ‘QList’ requested

error: no matching function for call to ‘QList::append(QwtPlotCurve&)’
void QList::append(const T&) [with T = QwtPlotCurve]

note: candidates are:

note: void QList::append(const T&) [with T = QwtPlotCurve]

note: no known conversion for argument 1 from ‘QwtPlotCurve*’ to ‘const QwtPlotCurve&’

note: void QList::append(const QList&) [with T = QwtPlotCurve]

note: no known conversion for argument 1 from ‘QwtPlotCurve*’ to ‘const QList&’

…

I says the QwtPlotCurve should be constant, but I don’t know how to deal with it.
I don’t know neither whether storing curves in a QList and then removing it (on user demand) from the plot is the right approach.


After the answer of sjwarner I tried the following:

QList<QwtPlotCurve*> curves;
QwtPlotCurve* curve1 = new QwtPlotCurve();
QwtPlotCurve* curve2 = new QwtPlotCurve();
curves->append(curve1);
curves->append(curve2);

and I got the following error:

error: base operand of ‘->’ has non-pointer type ‘QList’
error: base operand of ‘->’ has non-pointer type ‘QList’

I understood this error in the following way:
curves is a QList and it should be a pointer to the QList.

If I try:

QList<QwtPlotCurve*>* curves = new QList<QwtPlotCurve*>;
QwtPlotCurve* curve1 = new QwtPlotCurve();
QwtPlotCurve* curve2 = new QwtPlotCurve();
curves->append(curve1);
curves->append(curve2);

it works fine.
I am going to look at “Implicit sharing” pointed by sjwarner to get rid of “new” operators.

  • 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-03T20:24:42+00:00Added an answer on June 3, 2026 at 8:24 pm

    You have two problems:

    1. As commented by Kamil Klimlek above, you are declaring your QList object on the stack, and then trying to allocate it on the heap – since new returns a pointer to the type of object you are newing, so you are effectively trying to do the following:

      QList<T> = *QList<T>
      

      As an aside: it is very rare that you’ll need to new off a QList, since Qt implements implicit sharing for all of its container classes – in a nutshell, you can confidently declare all Qt containers (and plenty of other classes besides) as stack objects and pass-by-value if the contained data is needed elsewhere – Qt will handle all of the memory efficiencies and object cleanup.

      Read this for more info.

    2. You are declaring a QList of objects and trying to fill it with pointers to objects. you need to decide whether you want your QList to contain copies of the data:

      QList<QwtPlotCurve> curves;
      QwtPlotCurve curve1();
      QwtPlotCurve curve2();
      curves.append(curve1);
      curves.append(curve2);
      

      Or whether you want to allocate your QwtPlotCurves on the heap and store pointers to them in the QList:

      QList<QwtPlotCurve*> curves;
      QwtPlotCurve* curve1 = new QwtPlotCurve();
      QwtPlotCurve* curve2 = new QwtPlotCurve();
      curves.append(curve1);
      curves.append(curve2);
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Rake (like make) is able to have many targets/tasks specified on invocation. Is it
I would like to make smth like this: class MyModel < ActiveRecord::Base has_many :locations
i would like to make a stored proc or something that will have only
I would like to make three inner divs have the same size. Can you
I have in my project old version (1.2) Propel. I would like make query:
Hi I have not well understand how rhino license works. I would like make
I would like to make my img.icon_zoom (line 4) only appear with mouseover. This
I would like to make the decimals in the following string display as superscript:
I would like make a script using PHP (probably need JS) to send POST
I would like make an extension method for the generic class A which takes

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.