matplotlib crosshair cursor in PyQt dialog does not show up
<p>I want to have a crosshair at the cursor in my <code>matplotlib</code> window. This works out in the example, given in the <a href="http://matplotlib.org/examples/widgets/cursor.html" rel="nofollow">matplotlib gallery</a>. But unfortunately, it does not work if I have the matplotlib widget in a Qt dialog window (<code>QDialog</code>).</p>

<p>This is my sample of code, where I want to instantiate the <code>matplotlib.widgets.Cursor</code> object, but nothing shows up. </p>

<pre><code>import sys
from PyQt4 import QtGui
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
import matplotlib.pyplot as plt
from matplotlib.widgets import Cursor

class Window(QtGui.QDialog):
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)
        self.figure = plt.figure(facecolor='white')
        self.canvas = FigureCanvas(self.figure)
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.canvas)
        self.setLayout(layout)

        ''' plot some random stuff '''
        ax = self.figure.add_subplot(111)
        self.ax = ax
        ax.plot([1,2])

        # Set cursor        
        Cursor(self.ax, useblit=False, color='red', linewidth=1)
        self.canvas.draw()

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    main = Window()
    main.show()
    sys.exit(app.exec_())
</code></pre>

<p>Can someone help?</p>