Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, January 2007
QStyleOptionButton with hand cursor


Message 1 in thread

Hi,

Qt 4.1.2

I have a QStyleOptionButton which I am using as a fake widget.
I want to change its cursor to PointingHand type. I cant seem to find a
staright forward way to do it.
Need help for this.

Thanks

--
 [ signature omitted ] 

Message 2 in thread

Jaya Meghani wrote:
> Hi,
> 
> Qt 4.1.2
> 
> I have a QStyleOptionButton which I am using as a fake widget.
> I want to change its cursor to PointingHand type. I cant seem to find a
> staright forward way to do it.
> Need help for this.

Hmmm, usually you would call QWidget::setCursor (Qt::PointingHandCursor) 
on a given widget - so I assume your problem is how to get the actual 
QWidget, given the QStyleOptionButton? And I don't quite understand what 
you mean with "fake widget", since QStyleOptionButton is NOT a widget. 
Do you mean an "invisible widget" which should simply define an area 
where the mouse cursor changes?

Is what you want that the mouse pointer changes into a hand on a 
(single) given area? So why not define an invisible QFrame (without 
borders etc.) on the given widget and call QFrame::setCursor (...) on 
that frame?

Or is what you want that EACH QPushButton should have a point hand 
cursor (specified via the style classes, and not for each single 
QPushButton that happens to be in your application)? This is probably a 
bit trickier and I don't know of any solution how to specify the mouse 
cursor for a given widget type, using QStyle(-Option)...

Cheers, Oliver

--
 [ signature omitted ] 

Message 3 in thread

> > Hi,
> > 
> > Qt 4.1.2
> > 
> > I have a QStyleOptionButton which I am using as a fake widget.
> > I want to change its cursor to PointingHand type. I cant 
> seem to find 
> > a staright forward way to do it.
> > Need help for this.
> 
> Hmmm, usually you would call QWidget::setCursor 
> (Qt::PointingHandCursor) on a given widget - so I assume your 
> problem is how to get the actual QWidget, given the 
> QStyleOptionButton? And I don't quite understand what you 
> mean with "fake widget", since QStyleOptionButton is NOT a widget. 
> Do you mean an "invisible widget" which should simply define 
> an area where the mouse cursor changes?
 By fake widget I meant that I am not using an actual pushbutton but
just a QStyleOptionButton to draw it.

> 
> Is what you want that the mouse pointer changes into a hand on a
> (single) given area? So why not define an invisible QFrame 
> (without borders etc.) on the given widget and call 
> QFrame::setCursor (...) on that frame?

I have this QStyleOptionButton in lots of rows in a QTreeWidget. So
adding an invisible frame would mean so many extra widgets for each row
just to change the arrow.
I was wondering if there is a cleaner way to do it? Like setting style?
> 
> Or is what you want that EACH QPushButton should have a point 
> hand cursor (specified via the style classes, and not for 
> each single QPushButton that happens to be in your 
> application)? This is probably a bit trickier and I don't 
> know of any solution how to specify the mouse cursor for a 
> given widget type, using QStyle(-Option)...
> 
> Cheers, Oliver
> 
> --
> To unsubscribe - send a mail to 
> qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the 
> subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 

--
 [ signature omitted ] 

Message 4 in thread

Jaya Meghani schrieb:
>>> Hi,
>> ...
>  By fake widget I meant that I am not using an actual pushbutton but
> just a QStyleOptionButton to draw it.
> ...
> I have this QStyleOptionButton in lots of rows in a QTreeWidget. So
> adding an invisible frame would mean so many extra widgets for each row
> just to change the arrow.
> I was wondering if there is a cleaner way to do it? Like setting style?

Hmmm... from the Qt docs I really don't see how you could specify the
mouse cursor for a given style option (I'm not saying there is no way to
set it; I simply don't know). I think you really need to use a real
QWidget (QPushButton in your case) as to define the mouse cursor for it.

If you have multiple of those buttons you could always subclass from
QPushButton, e.g. "MouseHandPushButton", hard-code the mouse cursor
there (e.g. in the c'tor) and use this in your QTreeWidget.

Cheers, Oliver

--
 [ signature omitted ]