QCustomPlot Discussion and Comments

array of QCPItemRectReturn to overview

I have lots of rectangle Item that I want to access to them with index so I want to make an array of RecItem, I declare it this way:

const int mySize = 200
QCPItemRect *item[mySize] = new QCPItemRect(ui->myCusomPlot);

but it is n't true. I've tested many ways but nothing has happened, by the way one of the reason that I want to declare an array is that when new many Items in a loop the program would become extremely slow. so I want to ask you how can I do that.

how can we mange a lots of Items say 8000 , if we declare it the program became very slow, do you have any solution to overcome this or it is one of the restriction in this library please response to my question...


The above code is incorrect C++ for arrays, please see an according C++ tutorial. Further, in Qt, I suggest you rather use QVector or QList.
Anyhow, the performance won't increase by changing the container, because it's the drawing that takes most of the time. So 8000 rect items are very unusual and seem like a design flaw in your application. What are you trying to achieve with 8000 rect items? Might it be more sensible to create a new plottable class for that purpose?

ooh, I'm so sorry for the code. I don't know exactly what happen that make me to do this mistake just I wanted to show my purpose :o, by the way, the thing exactly intend to do is that I want to have screen that can be change its pixel's color(the screen is 800*100 or 800*10 pixel and something that I name it pixel is a rectangle or square that its width are 1 or 0.5 and its height is 1 or 0.5 respectively) and above this screen do my usual plotting operations meanwhile when zooming is happened to the plot, the screen would zoom within the plot too. the color of the pixels is changed by values that I get separately from the network and the plot values are gotten from another resource. can you please explain more about new plottable class?

any Idea can be appreciated...