cedrix
5th May 2011, 20:23
Hello,
I am using PyQwt, and I have some issues for saving charts.
Here is my code :
def saveChart(self):
fileName = QtGui.QFileDialog.getSaveFileName(self, 'Export File Name', 'JPGgraph', 'JPG Documents (*.jpg)')
if not fileName.isEmpty():
if not fileName.toLower().endsWith('.jpg'):
fileName += '.jpg'
currentPlot = self.plots[self.graphComboBox.currentIndex()].plot
filtre = QwtPlotPrintFilter()
screen = QtGui.QPixmap.grabWidget(currentPlot)
#screen.fill(QtCore.Qt.white)
#print currentPlot.size()
#print currentPlot.rect()
#print currentPlot.sizeHint()
#print currentPlot.minimumSizeHint()
currentPlot.print_(screen, filtre)
screen.save(fileName, "JPG", -1)
I have several QwtPlot in a QStackWidget, which is in a QHorizontalLayout, which is in a QWidget which is the central widget of my QMainWindow.
When I try to save on of my chart, either the width is higher than the height or the height is higher than the width.
The result is :
http://i55.tinypic.com/1zbdo2s.jpg
Or :
http://i53.tinypic.com/b6eb2e.jpg
Someone know what I should do to solve this issue ?
Thanks in advance,
Cédric
I am using PyQwt, and I have some issues for saving charts.
Here is my code :
def saveChart(self):
fileName = QtGui.QFileDialog.getSaveFileName(self, 'Export File Name', 'JPGgraph', 'JPG Documents (*.jpg)')
if not fileName.isEmpty():
if not fileName.toLower().endsWith('.jpg'):
fileName += '.jpg'
currentPlot = self.plots[self.graphComboBox.currentIndex()].plot
filtre = QwtPlotPrintFilter()
screen = QtGui.QPixmap.grabWidget(currentPlot)
#screen.fill(QtCore.Qt.white)
#print currentPlot.size()
#print currentPlot.rect()
#print currentPlot.sizeHint()
#print currentPlot.minimumSizeHint()
currentPlot.print_(screen, filtre)
screen.save(fileName, "JPG", -1)
I have several QwtPlot in a QStackWidget, which is in a QHorizontalLayout, which is in a QWidget which is the central widget of my QMainWindow.
When I try to save on of my chart, either the width is higher than the height or the height is higher than the width.
The result is :
http://i55.tinypic.com/1zbdo2s.jpg
Or :
http://i53.tinypic.com/b6eb2e.jpg
Someone know what I should do to solve this issue ?
Thanks in advance,
Cédric