[Qt-interest] Remove QPushButton's click effect

Bence Magyar mw.mzperx at gmail.com
Tue Aug 9 21:31:14 CEST 2011


Hello Pritam,

thank you for the advice, it was much quicker to solve it this way then to
hack-around a half day with QPushButton.

void mouseReleaseEvent(QMouseEvent *ev)

{

    emit clicked(ev->pos());

    //qDebug() << ev->pos().x() << ev->pos().y();

}

All the coding I did was this :)
Thanks again,
-Bence

2011/8/9 Pritam Ghanghas <pritam_ghanghas at infosys.com>

> Hi
>
> It should be doable with stylesheet. If you send some code that is not
> working, it can be corrected. Its very easy to make mistakes with
> stylesheet and qt will silently ignore wrong stylesheet.
>
> But why you want to use QPushButton for this task. QLabel seems to be
> much better alternative. You can track mouse yourself by reimplimenting
> one of the mouse*Event() virtuals and emit clicked(). QLabel provides
> very flexible APIs for displaying a pixmap.
>
>
> --
> Thanks,
> Pritam
>
>
> On Tue, 2011-08-09 at 19:20 +0530, Bence Magyar wrote:
> > Dear List,
> >
> >
> > As the subject states I want to remove QPushButton's click effect. By
> > click effect I mostly mean the orange-like half-transparent foreground
> > coloring. (It is orange-like since I am on Ubuntu, the coloring is
> > different on other systems/styles.)
> > I have been looking around for stuff like this but I only managed to
> > get rid of the moving effect of the pushbuttons content via setting a
> > padding in CSS.
> >
> >
> > These pages seemed to be the most useful:
> >
> http://doc.qt.nokia.com/4.6/stylesheet-examples.html#customizing-qpushbutton
> > http://stackoverflow.com/questions/1712199/styling-qpushbutton-with-css
> >
> >
> > So my objective is to get a widget I can display a picture on and this
> > widget has a clicked() signal without any graphical side-effect.
> >
> >
> > Is there a way of solving this simply without having to derive from
> > QAbstractButton or QPushButton and override the paint method?
> > My goal is quite simple after all so I hope there is an elegant way
> > instead of writing "tons" of code.
> >
> >
> >
> >
> > -Bence
>
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> solely
> for the use of the addressee(s). If you are not the intended recipient,
> please
> notify the sender by e-mail and delete the original message. Further, you
> are not
> to copy, disclose, or distribute this e-mail or its contents to any other
> person and
> any such actions are unlawful. This e-mail may contain viruses. Infosys has
> taken
> every reasonable precaution to minimize this risk, but is not liable for
> any damage
> you may sustain as a result of any virus in this e-mail. You should carry
> out your
> own virus checks before opening the e-mail or attachment. Infosys reserves
> the
> right to monitor and review the content of all messages sent to or from
> this e-mail
> address. Messages sent to or from this e-mail address may be stored on the
> Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110809/69b733d6/attachment.html 


More information about the Qt-interest-old mailing list