Don't know about the Python bindings, but Qwt 5.2 offers a class QwtPlotRescaler, that offers something like the "axis equal" feature.
In Qwt 6.1 you find the rescaler example, that shows how to use it.
Question
I want to plot figures with qwtplot like in Matlab with axis equal, so that a circle looks like a circle and not like an ellipse.
I have not found a function like "axis equal", or have missed one?
So I want to write my own function. Therefore I need the size of the drawing area. I think "ployLayout().canvasRect()" should give me the size.
When I use QtDesigner and uic, that works fine and I get the values, e.g:
PyQt4.QtCore.QRect(11, 0, 458, 412)
But if I programm the GUI on my own is does not work and the result is: PyQt4.QtCore.QRect()
This is my code
import sys
from PyQt4 import QtCore, QtGui, Qt
import PyQt4.Qwt5 as Qwt
class mainWindow(QtGui.QDialog):
def __init__(self, numberOfObjects, parent=None):
QtGui.QDialog.__init__(self, parent)
okButton = QtGui.QPushButton(self.tr("OK"))
cancelButton = QtGui.QPushButton(self.tr("Cancel"))
self.connect(okButton, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("accept()"))
self.connect(cancelButton, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("reject()"))
self.testPlot = Qwt.QwtPlot(self)
buttonLayout = QtGui.QHBoxLayout()
buttonLayout.addStretch(1)
buttonLayout.addWidget(okButton)
buttonLayout.addWidget(cancelButton)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addWidget(self.testPlot)
mainLayout.addLayout(buttonLayout)
self.setLayout(mainLayout)
self.resize(450, 250)
cr = self.testPlot.plotLayout().canvasRect()
print cr
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
win = mainWindow(0)
sys.exit(win.exec_())
Can anyone help me?
I use Python 2.7, QT4 and Qwt5.
Solution
Don't know about the Python bindings, but Qwt 5.2 offers a class QwtPlotRescaler, that offers something like the "axis equal" feature.
In Qwt 6.1 you find the rescaler example, that shows how to use it.