PDA

View Full Version : changing appearance of the cursor in QwtPlotPicker?



lazierbug
14th October 2011, 21:18
Is it possible to change the appearance of the mouse cursor inside QwtPlotPicker from the large cross symbol to something else?

Spitfire
17th October 2011, 09:51
I don't think you can do it on the Picker, but you can on Canvas: QwtPlotCanvas::setCursor(Qt::ForbiddenCursor (http://doc.qt.nokia.com/stable/qt.html#CursorShape-enum));
You can even specify your own custom cursor if you want.
http://doc.qt.nokia.com/stable/qcursor.html

Uwe
17th October 2011, 10:06
I don't think you can do it on the Picker, ...

Of course you can. There are a some basic options how to display the rubberband and if none of them fits you can overload drawRubberband.

Uwe

lazierbug
17th October 2011, 19:09
Hi Spitfire & Uwe,

Thanks for your replies.

@Uwe, how does one go about overloading the drawRubberBand? I've so far defined a customized Picker function with the following (i.e. if I wanted to change the "+" cursor into a rectangle)? The following doesn't compile, btw :(. I get errors for

error 1: invalid use of incomplete type ‘struct QPainter’
error 2: forward declaration of ‘struct QPainter’




class MyPicker: public QwtPlotPicker
{
public:
MyPicker():QwtPlotPicker() {};

virtual void drawRubberBand(QPainter *p) const
{
QRect myNewCursor = QRect(0,0,10,10);
p->drawRect(myNewCursor); // error 1 here
}
};

class MainWindow : public QMainWindow { // error 2 here
etc.
}

Spitfire
18th October 2011, 09:17
add
#include <QPainter>

lazierbug
18th October 2011, 11:49
Now it compiles! Thanks!

But this doesn't replace the little white "+"-symbol? Is this really part of the rubber band?

Uwe
18th October 2011, 12:10
No this is the cursor:


plot()->canvas()->setCursor( ... );
See http://doc.trolltech.com/4.7/qwidget.html#cursor-prop

Uwe