[Qt-interest] click method for Qlabel

Arnold Krille arnold at arnoldarts.de
Mon Aug 31 09:27:01 CEST 2009


On Monday 31 August 2009 08:51:47 Yuvaraj R wrote:
> Hi i want to emit the signals from Qlabel class,when label is clciked..

A label that is clickable is a button. Please do your users a favour and use a 
button.
Really if you start mixing labels that aren't clickable and label that are, 
you confuse your users. At first they won't find your buttons because they look 
like labels, then they will try to click on every label and complain if 
something doesn't react. And they will also complain at other authors for 
their apps. So, even if you can handle the bug-reports, I don't want to 
explain my users that they learned something wrong from your app.

If you do not want the typical QPushButton, look at the alternatives 
inheriting from QAbstractButton. Or implement your own deriving from 
QAbstractButton.

> But  Keypressevent is not virtual in Qlabel class..So we can't override it.

Why? QLabel inherits from QFrame which inherits from QWidget. And there 
keyPressEvent is virtual. If its virtual once, its virtual everywhere.

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090831/46c68d6e/attachment.bin 


More information about the Qt-interest-old mailing list