class KURLLabel

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

Definition#include <kurllabel.h>
InheritsQLabel (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Slots

Signals

Protected Methods


Detailed Description

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.

 KURLLabel (QWidget* parent = 0L, const char* name = 0L)

KURLLabel

Default constructor.

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

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

KURLLabel

Convenience constructor.

parent and name are passed to QLabel.

Parameters:
urlis the URL emitted when the label is clicked.
textis the displayed string. If it's equal to QString::null the url will be used instead.

 ~KURLLabel ()

~KURLLabel

[virtual]

Destructs the label.

const QString&  url ()

url

[const]

Returns the URL.

const QString&  tipText ()

tipText

[const]

Returns the current tooltip text.

bool  useTips ()

useTips

[const]

Returns: true if a tooltip will be displayed.

See also: setTipText()

bool  useCursor ()

useCursor

[const]

Returns: true if the cursor will change while over the URL.

See also: setUseCursor, ()

bool  isGlowEnabled ()

isGlowEnabled

[const]

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

bool  isFloatEnabled ()

isFloatEnabled

[const]

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.

const QPixmap*  altPixmap ()

altPixmap

[const]

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

void  setUnderline (bool on = true)

setUnderline

[slot]

Turns on or off the underlining.

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

void  setURL (const QString& url)

setURL

[slot]

Sets the URL for this label to url.

See also: url

void  setFont (const QFont&)

setFont

[virtual slot]

Overridden for internal reasons; the API remains unaffected.

void  setUseTips (bool on = true)

setUseTips

[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.

void  setTipText (const QString& tip)

setTipText

[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  setHighlightedColor (const QColor& highcolor)

setHighlightedColor

[slot]

Sets the highlight color.

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

void  setHighlightedColor (const QString& highcolor)

setHighlightedColor

[slot]

This is an overloaded version for convenience.

See also: setHighlightedColor()

void  setSelectedColor (const QColor& selcolor)

setSelectedColor

[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  setSelectedColor (const QString& selcolor)

setSelectedColor

[slot]

This is an overloaded version for convenience.

See also: setSelectedColor()

void  setUseCursor (bool on, QCursor* cursor = 0L)

setUseCursor

[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:
onwhether a custom cursor should be displayed.
cursoris the custom cursor. 0L indicates the default "hand cursor".

void  setGlow (bool glow = true)

setGlow

[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  setFloat (bool do_float = true)

setFloat

[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.

void  setAltPixmap (const QPixmap& altPix)

setAltPixmap

[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  enteredURL (const QString& url)

enteredURL

[signal]

Emitted when the mouse has passed over the label.

Parameters:
urlThe URL for this label.

void  enteredURL ()

enteredURL

[signal]

Emitted when the mouse has passed over the label.

void  leftURL (const QString& url)

leftURL

[signal]

Emitted when the mouse is no longer over the label.

Parameters:
urlThe URL for this label.

void  leftURL ()

leftURL

[signal]

Emitted when the mouse is no longer over the label.

void  leftClickedURL (const QString& url)

leftClickedURL

[signal]

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

Parameters:
urlThe URL for this label.

void  leftClickedURL ()

leftClickedURL

[signal]

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

void  rightClickedURL (const QString& url)

rightClickedURL

[signal]

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

Parameters:
urlThe URL for this label.

void  rightClickedURL ()

rightClickedURL

[signal]

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

void  middleClickedURL (const QString& url)

middleClickedURL

[signal]

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

Parameters:
urlThe URL for this label.

void  middleClickedURL ()

middleClickedURL

[signal]

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

void  mouseReleaseEvent (QMouseEvent*)

mouseReleaseEvent

[protected virtual]

Overridden for internal reasons; the API remains unaffected.

void  enterEvent (QEvent*)

enterEvent

[protected virtual]

Overridden for internal reasons; the API remains unaffected.

void  leaveEvent (QEvent*)

leaveEvent

[protected virtual]

Overridden for internal reasons; the API remains unaffected.

void  virtual_hook ( int id, void* data )

virtual_hook

[protected virtual]