PDA

View Full Version : specify an Icon when mouseOver a QSizeGrip



vonCZ
19th May 2009, 17:01
I am guessing that there are 4 possible system Icons that pop-up when you mouse-Over a QSizeGrip: the double arrow up-down, left-right, 45 degrees one way, or 45 degrees the other. My problem: I've set my QSizeGrip to move up and down (its parent widget has a fixed width). But when I mouseOver the SizeGrip, the up-down Icon doesn't appear. Instead, one of the 45 degree icons appears. How can I fix this?

My QSizeGrip is already subclassed so that I can implement my own paintEvent; is there an additional function I can add to select which icon appears when the sizeGrip is moused Over? One thing I've thought of doing: turning off the widget's (presumably) internal mouse-over behavior, adding an eventFilter, and then including my own pop-up icon in the eventFilter. But this seems cumbersome/unnecessary.

thanx

wysota
20th May 2009, 22:49
QWidget::setCursor()

vonCZ
21st May 2009, 17:04
Now I'll follow-up my embarrassingly easy question :o ...with an embarrassing observation: it doesn't work.:confused:

I tested it on a QSlider; no problem, it works. But on the QSizeGrip: I still get the default icon.

wysota
21st May 2009, 21:56
I just had a look at the code. Changing the cursor will not be easy. It might be better if you just disable the size grip although even then the cursor keeps its properties.

vonCZ
22nd May 2009, 16:41
It might be better if you just disable the size grip

I'm not sure what you mean there; I want the sizeGrip enabled so I can use it, of course.


Changing the cursor will not be easy.

I'm actually already sub-classing this QSizeGrip so that I can implement my own paintEvent. Is there not an additional function I can add to over-ride the cursor behavior? Perhaps by "disable the size grip" you mean disable it's mouseOver/Cursor feature, and either re-implement it here somehow... or add an installEventFilter(this) to the sizeGrip widget and change the cursor in my this::eventFilter(QObject *o, QEvent *e), something like:



eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::Enter)
{
if(obj == mySizeGrip)
{
QRect rect = mySizeGrip->geometry();
Qt_upDown_icon->move( rect.right(), rect.bottom())
Qt_upDown_icon->show();
// etc.....


Anyway, just curious what you think. Thanks.

wysota
22nd May 2009, 20:32
I'm not sure what you mean there; I want the sizeGrip enabled so I can use it, of course.
You'll be able to resize the dialog by dragging regardless of the presence of QSizeGrip.


I'm actually already sub-classing this QSizeGrip so that I can implement my own paintEvent. Is there not an additional function I can add to over-ride the cursor behavior?
You have to reimplement a bunch of events and the event filter. It might be much easier to implement the size grip from scratch but even then I'm not sure you'll be able to manipulate the cursor the way you want.


Perhaps by "disable the size grip" you mean disable it's mouseOver/Cursor feature,
I mean calling QDialog::setSizeGripEnabled(false).

vonCZ
24th May 2009, 13:09
I mean calling QDialog::setSizeGripEnabled(false).

I've actually never used a QDialog; the widget I want to stretch vertically is simply a QWidget with various layouts & widgets. See attached image; the mySizeGrip is at the very bottom in the middle (it's a subclassed QSizeGrip with the paintEvent re-implemented).

So maybe I should use a QDialog, except far as I can tell you can either enable/disable sizeGrip, and not just have it enabled for one side (the bottom). Oh well, screw it.

wysota
24th May 2009, 13:58
Hmm... Isn't QSplitter what you want?