I have a weird problem with QwtPlotRenderer. I need to export a plot to file. The plot itself renders properly (it is also inserted as a widget into a tab in my program). However, when I tried to render the plot using QwtPlotRenderer renderTo or renderDocument methods, I have found that the scales of both axes are always set to 0 to 100. At the same time, exportTo method of QwtPlotRenderer works correctly, both with autoscaling and setting scales in code. I have looked through Qwt sources, found that exportTo method calls renderDocument after showing QFileDialog::getSaveFileName, copied most of the exportTo code to my program and finally found that the renderDocument method requires a call to static method of QFileDialog to work properly.

The following code works as expected:

Qt Code:
  1. QwtPlotRenderer renderer;
  2. QFileDialog::getSaveFileName(NULL);
  3. renderer.renderDocument(plot, "test.svg", QSizeF(100, 100));
To copy to clipboard, switch view to plain text mode 

This code does not:

Qt Code:
  1. QwtPlotRenderer renderer;
  2. renderer.renderDocument(plot, "test.svg", QSizeF(100, 100));
To copy to clipboard, switch view to plain text mode 

QFileDialog::getOpenFileName or QFileDialog::getExistingDirectory may be used instead of QFileDialog::getSaveFileName. The effect does not depend on the file format (I have tested PNG, SVG and PDF). I am using Qt 5.2.1 and Qwt 6.1.0 under Windows 7, C++ compiler is MinGW 4.8.0 32-bit.