QCustomPlot Discussion and Comments

change background pixmap during runtimeReturn to overview

Hi everybody,

I'm trying to implement a changeable plot background into my application, which I would like to control via MainWindow::on_QCheckBox_clicked(bool checked) event as follows:
void MainWindow::on_QCheckBox_clicked(bool checked)
if (checked) ui->customPlot->axisRect()->setBackground(QPixmap(":/XXX_2.png"));
else ui->customPlot->axisRect()->setBackground(QPixmap(":/XXX_1.png"));

Unfortunately it does not seem to be working like that. I have to mention that at this point there is already one picture setted up beforehand (XXX_1). Do I have to delete preveous configuration first or is there an update function I have missed out.

Thanks in advance for your help

do you call customPlot->replot(); after changing the background?
Also check out QCPItemPixmap if you want to pin background image to coordinates and not just the whole plot background.

are you sure it is actually going into that method? also , did you actually name your checkbox 'QCheckBox'? i dont think the meta object system will let you have a capital name for the method if you want it to connect properly.

Hi Isso and Ian,

many thanks for your replies.
Since I'm very new with using this widged and qt in particular It was not clear to me that I have to call ->replot() in this case as well. This was the simple solution. (-.-)

I renamed it in order to clarify that I would like to initiate the event (changing the background) with a checkbox. Unfortunately I took the class name. Sorry for the misunderstanding.

So, thanks again for the quick answer!