[Qt-interest] Signals on QLabel
Keshava Krishna
keshavkrishna88 at gmail.com
Tue Jun 9 03:38:15 CEST 2009
You can do one thing, write your own class, make QLabel parent of this
class...in this class u can override mousePressEvent and emit a signal say
clicked in it...
u can use this class in ur application instead of QLabel..
On Mon, Jun 8, 2009 at 8:31 PM, Santhosh Y <santhosh at softjin.com> wrote:
> Hi,
>
> Following is a simple QLabel derived class; I would like to know, when I
> click on the QLabel
> which signal would be emitted.
>
> When I tried with the following example, none of the 2-signals are
> emitted when I press on the label.
>
> What is wrong here!
>
> ------------------------------------------------------------------------------------------------
> class MyLabel: public QLabel
> {
> Q_OBJECT
> public:
> MyLabel (const QString& s, QWidget* parent)
> : QLabel(s, parent)
> {
> connect (this, SIGNAL (linkActivated (const QString &)),
> this, SLOT (emittedLinkActivated(const QString&)));
>
>
> connect (this, SIGNAL (linkHovered (const QString &)),
> this, SLOT (emittedLinkHovered(const QString&)));
> }
>
> public slots:
>
> void emittedLinkHovered (const QString& s) {
> std::cout << "emittedLinkHovered" << s.toStdString() <<
> std::endl;
> }
>
> void emittedLinkActivated (const QString& s) {
> std::cout << "emittedLinkActivated" << s.toStdString() <<
> std::endl;
> }
>
> };
>
> --
> ----------------------------------------------------
> Y Santhosh Kumar
> Senior Software Engineer
> SoftJin Technologies Private Limited
> Unit No. 102, Mobius Tower,
> I Floor, SJR I - Park,
> EPIP, White Field,
> Bangalore - 560066, India
> U : www.softjin.com
> E : santhosh at softjin.com
> T : +91-80-41779999
> M : +91-9740535265
> ----------------------------------------------------
>
>
>
> Business Disclaimer
> ____________________________________________________________
> This e-mail message and any files transmitted with it are intended solely
> for the use of the individual or entity to which they are addressed.
> It
> may contain confidential, proprietary or legally privileged
> information.
> If you are not the intended recipient please be advised that you have
> received this message in error and any use is strictly prohibited. Please
> immediately delete it and all copies of it from your system, destroy any
> hard copies of it and notify the sender by return mail. You must
> not,
> directly or indirectly, use, disclose, distribute, print, or copy any
> part of
> this message if you are not the intended recipient.
> ___________________________________________________________
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
Regards,
Keshava.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090609/c706addb/attachment.html
More information about the Qt-interest-old
mailing list