I can't paste the whole code for the peak labels since it is quite long. If anyone is interested nonetheless:
https://cutenmr.svn.sourceforge.net/.../peaklabel.cpp

I will instead paste snippets of a minimal example I created. I already expected that it is caused by my (wrong) implementation.

My minimal example is a straight red line that is painted from the top of the canvas to the 0 position of my y-axis. The x-position is "3" in the unit of the x-axis. This is a screenshot of the (expected) result:

screen2.jpg

I mainly used the code from the cpupiemarker example for implementing my QwtPlotItem:

First, I get the QwtScaleMap from my PlotWidget (which is part of a parameters object that I can easily pass to other objects):

Qt Code:
  1. QwtScaleMap xMap = par->spectrum_plot->canvasMap(QwtPlot::xBottom);
  2. QwtScaleMap yMap = par->spectrum_plot->canvasMap(QwtPlot::yLeft);
To copy to clipboard, switch view to plain text mode 

Then the code for drawing the line:

Qt Code:
  1. p->save();
  2. p->setPen(QColor(Qt::red));
  3. p->drawLine(QPointF(xMap.transform(3), 0), QPointF(xMap.transform(3), yMap.transform(0)));
  4. p->restore();
To copy to clipboard, switch view to plain text mode 

And that's all you can find in my draw() function. Everything else is identical to the cpupiemarker example.

I attach the QwtPlotItem using this code:

Qt Code:
  1. peakLabel* pL = new peakLabel(par);
  2. pL->attach(par->spectrum_plot);
To copy to clipboard, switch view to plain text mode 

And the (unexpected) result of the exported image is:

export2.jpg

If you need other parts of the code to evaluate what my mistake is, just ask.

Many thanks