Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

KURLLabel Class Reference

A drop-in replacement for QLabel that displays hyperlinks. More...

#include <kurllabel.h>

List of all members.

Public Slots

void setUnderline (bool on=true)
void setURL (const QString &url)
virtual void setFont (const QFont &)
void setUseTips (bool on=true)
void setTipText (const QString &tip)
void setHighlightedColor (const QColor &highcolor)
void setHighlightedColor (const QString &highcolor)
void setSelectedColor (const QColor &selcolor)
void setSelectedColor (const QString &selcolor)
void setUseCursor (bool on, QCursor *cursor=0L)
void setGlow (bool glow=true)
void setFloat (bool do_float=true)
void setAltPixmap (const QPixmap &altPix)

Signals

void enteredURL (const QString &url)
void enteredURL ()
void leftURL (const QString &url)
void leftURL ()
void leftClickedURL (const QString &url)
void leftClickedURL ()
void rightClickedURL (const QString &url)
void rightClickedURL ()
void middleClickedURL (const QString &url)
void middleClickedURL ()

Public Methods

 KURLLabel (QWidget *parent=0L, const char *name=0L)
 KURLLabel (const QString &url, const QString &text=QString::null, QWidget *parent=0L, const char *name=0L)
virtual ~KURLLabel ()
const QString & url () const
const QString & tipText () const
bool useTips () const
bool useCursor () const
bool isGlowEnabled () const
bool isFloatEnabled () const
const QPixmap * altPixmap () const

Protected Methods

virtual void mouseReleaseEvent (QMouseEvent *)
virtual void enterEvent (QEvent *)
virtual void leaveEvent (QEvent *)


Detailed Description

A drop-in replacement for QLabel that displays hyperlinks.

A label class that supports displaying an active hyperlink.

KURLLabel is a drop-in replacement for QLabel that handles text in a fashion similar to how an HTML widget handles hyperlinks. The text can be underlined (or not) and set to different colors. It can also "glow" (cycle colors) when the mouse passes over it.

KURLLabel also provides signals for several events, including the mouse leaving and entering the text area and all forms of mouse clicking.

A typical usage would be something like so:

     KURLLabel *address = new KURLLabel(this);
     address->setText("My homepage");
     address->setURL("http://www.home.com/~me");
     connect(address, SIGNAL(leftClickedURL(const QString&)),
                      SLOT(processMyURL(const QString&)));
 

In this example, the text "My homepage" would be displayed as blue, underlined text. When the mouse passed over it, it would "glow" red. When the user clicks on the text, the signal leftClickedURL() would be emitted with "http://www.home.com/~me" as its argument.

Author:
Kurt Granroth <granroth@kde.org> (Interface) , Peter Putzer <putzer@kde.org> (Rewrite)
Version:
Id:
kurllabel.h,v 1.20 2002/03/04 00:51:52 lunakl Exp

Definition at line 63 of file kurllabel.h.


Constructor & Destructor Documentation

KURLLabel::KURLLabel QWidget *    parent = 0L,
const char *    name = 0L
 

Default constructor.

Use setURL() and setText() or QListView::setPixmap() to set the resp. properties.

KURLLabel::KURLLabel const QString &    url,
const QString &    text = QString::null,
QWidget *    parent = 0L,
const char *    name = 0L
 

Convenience constructor.

Parameters:
url  is the URL emitted when the label is clicked.
text  is the displayed string. If it's equal to QString::null the url will be used instead.
parent and name are passed to QLabel.

virtual KURLLabel::~KURLLabel   [virtual]
 

Destructs the label.


Member Function Documentation

const QPixmap* KURLLabel::altPixmap  
 

Returns:
the alternate pixmap (may be 0L if none was set).

void KURLLabel::enteredURL   [signal]
 

Emitted when the mouse has passed over the label.

void KURLLabel::enteredURL const QString &    url [signal]
 

Emitted when the mouse has passed over the label.

Parameters:
url  The URL for this label.

virtual void KURLLabel::enterEvent QEvent *    [protected, virtual]
 

Overridden for internal reasons; the API remains unaffected.

bool KURLLabel::isFloatEnabled  
 

This feature is very similar to the "glow" feature in that the color of the label switches to the selected color when the cursor passes over it. In addition, underlining is turned on for as long as the mouse is overhead. Note that if "glow" and underlining are both already turned on, this feature will have no visible effect.

bool KURLLabel::isGlowEnabled  
 

When this is on, the text will switch to the selected color whenever the mouse passes over it.

virtual void KURLLabel::leaveEvent QEvent *    [protected, virtual]
 

Overridden for internal reasons; the API remains unaffected.

void KURLLabel::leftClickedURL   [signal]
 

Emitted when the user clicked the left mouse button on this label.

void KURLLabel::leftClickedURL const QString &    url [signal]
 

Emitted when the user clicked the left mouse button on this label.

Parameters:
url  The URL for this label.

void KURLLabel::leftURL   [signal]
 

Emitted when the mouse is no longer over the label.

void KURLLabel::leftURL const QString &    url [signal]
 

Emitted when the mouse is no longer over the label.

Parameters:
url  The URL for this label.

void KURLLabel::middleClickedURL   [signal]
 

Emitted when the user clicked the left mouse button on this label.

void KURLLabel::middleClickedURL const QString &    url [signal]
 

Emitted when the user clicked the middle mouse button on this label.

Parameters:
url  The URL for this label.

virtual void KURLLabel::mouseReleaseEvent QMouseEvent *    [protected, virtual]
 

Overridden for internal reasons; the API remains unaffected.

void KURLLabel::rightClickedURL   [signal]
 

Emitted when the user clicked the left mouse button on this label.

void KURLLabel::rightClickedURL const QString &    url [signal]
 

Emitted when the user clicked the right mouse button on this label.

Parameters:
url  The URL for this label.

void KURLLabel::setAltPixmap const QPixmap &    altPix [slot]
 

Sets the "alt" pixmap.

This pixmap will be displayed when the cursor passes over the label. The effect is similar to the trick done with 'onMouseOver' in javascript.

See also:
altPixmap()

void KURLLabel::setFloat bool    do_float = true [slot]
 

Turns on or off the "float" feature.

This feature is very similar to the "glow" feature in that the color of the label switches to the selected color when the cursor passes over it. In addition, underlining is turned on for as long as the mouse is overhead. Note that if "glow" and underlining are both already turned on, this feature will have no visible effect. By default, it is false.

virtual void KURLLabel::setFont const QFont &    [virtual, slot]
 

Overridden for internal reasons; the API remains unaffected.

void KURLLabel::setGlow bool    glow = true [slot]
 

Turns on or off the "glow" feature.

When this is on, the text will switch to the selected color whenever the mouse passes over it. By default, it is true.

void KURLLabel::setHighlightedColor const QString &    highcolor [slot]
 

This is an overloaded version for convenience.

See also:
setHighlightedColor()

void KURLLabel::setHighlightedColor const QColor &    highcolor [slot]
 

Sets the highlight color.

This is the default foreground color (non-selected). By default, it is blue.

void KURLLabel::setSelectedColor const QString &    selcolor [slot]
 

This is an overloaded version for convenience.

See also:
setSelectedColor()

void KURLLabel::setSelectedColor const QColor &    selcolor [slot]
 

Sets the selected color.

This is the color the text will change to when either a mouse passes over it and "glow" mode is on or when it is selected (clicked). By default, it is red.

void KURLLabel::setTipText const QString &    tip [slot]
 

Specifies what text to display when tooltips are turned on.

If this is not used, the tip will default to the URL.

See also:
setUseTips()

void KURLLabel::setUnderline bool    on = true [slot]
 

Turns on or off the underlining.

When this is on, the text will be underlined. By default, it is true.

void KURLLabel::setURL const QString &    url [slot]
 

Sets the URL for this label to url.

See also:
url

void KURLLabel::setUseCursor bool    on,
QCursor *    cursor = 0L
[slot]
 

Turns the custom cursor feature on or off.

When this is on, the cursor will change to a custom cursor (default is a "pointing hand") whenever the cursor passes over the label. By default, it is on.

Parameters:
on  whether a custom cursor should be displayed.
cursor  is the custom cursor. 0L indicates the default "hand cursor".

void KURLLabel::setUseTips bool    on = true [slot]
 

Turns on or off the tool tip feature.

When this is on, the URL will be displayed as a tooltip whenever the mouse passes passes over it. By default, it is false.

const QString& KURLLabel::tipText  
 

Returns the current tooltip text.

const QString& KURLLabel::url  
 

Returns the URL.

bool KURLLabel::useCursor  
 

Returns:
true if the cursor will change while over the URL.
See also:
setUseCursor ()

bool KURLLabel::useTips  
 

Returns:
true if a tooltip will be displayed.
See also:
setTipText()


The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:28 2003 for kdelibs by doxygen1.2.18