QCustomPlot Discussion and Comments

Set Brush in Bar Chart only for specific tickReturn to overview

I have a problem with Bar Chart. I have one graph, but data on it has different types and I want to distinguish them by different colors. I tried so:

for (int i = 0; i < sortedClassifierResults.size(); i++)
        QColor penColor = ClassifierResultsWindow::questionTypeColor[sortedClassifierResults[i].first.type];
        QColor brushColor = ClassifierResultsWindow::questionTypeColor[sortedClassifierResults[i].first.type];
        questionClassifierPlotBar->addData(ticks[i], priorities[i]);

But as I supposed it didn't work. All bars have the last brush set. Is there any way to realize it or I need to create QCPBars on each type? The second way seems to me bad looking.
Thank you!

so each QCPBar has a pen and a brush and a data. whenever you call replot, it tells qcustomplot that you want to replot and it queues up a paint event. it will draw all of them at once.

The situation you have here is that you only have a single bar plot and you are trying to change the color while you are filling the data. this is not how qcustomplot functions.

If you want to do that, you either want to create a bunch of qcpbars or you want to create your own plot item and reimplement the paintevent.