KURLLabel Class Reference

[kdeui Index] [kdeui Hierarchy] [Headers]


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

#include <kurllabel.h>

Inherits: QLabel (qt)

Public Members

Public Slots

Protected Members

Signals


Detailed Description

A label class that supports displaying hyperlinks

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 char*)),
                      SLOT(processMyURL(const char*)));
 

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=0, const char* name=0, WFlags f=0) [public]

Constructor. Use this exactly like you would QLabel.

~KURLLabel() [public virtual]

Destructor.

const char* url() const [public]

Returns the URL. This will be the same as text() if setURL is not used.

Returns:
the URL.

const char* text() const [public]

Returns the current text.

Returns:
the current text.
See Also:
setText

const QPixmap* pixmap() const [public]

Returns the current pixmap.

Returns:
the current pixmap.
See Also:
setPixmap

QSize sizeHint() const [public]

Returns the recommended size for this label

void setTransparentMode(bool state) [public]

Enables or disables "transparent mode". If transparent mode is enabled, the label copies its own background from its parent widget so that it seems to be transparent. Transparent mode is disabled by default. Please note that the method does not repaint the widget, changes take effect on the next repainting. Transparent widgets do (currently) not work if there is another widget (a frame, for example) layered between this widget and its parent in Z-order.

void setGlow(bool glow = true) [public slot]

Turn 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 on.

void setFloat(bool do_float = true) [public slot]

Turn 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 off.

void setUseCursor(bool use_cursor, const QCursor* cursor = 0) [public slot]

Turn on or off the custom cursor feature. 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

void setUseTips(bool tips = true) [public slot]

Turn 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 off.

void setTipText(const char* tip) [public 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 setTextAlignment(TextAlignment align) [public slot]

Set the text alignment

void setUnderline(bool underline = true) [public slot]

Turn on or off the underlining. When this is on, the text will be underlined. By default, it is on

void setHighlightedColor(const QColor& highcolor) [public slot]

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

void setHighlightedColor(const char* highcolor) [public slot]

This is an overloaded version for convenience.

See Also:
setHighlightedColor

void setSelectedColor(const QColor& selcolor) [public slot]

Set 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 read

void setSelectedColor(const char* selcolor) [public slot]

This is an overloaded version for convenience.

See Also:
setSelectedColor

void setBackgroundColor(const QColor& bgcolor) [public slot]

Set the background color. By default, it is set to the KDE background color.

void setBackgroundColor(const char* bgcolor) [public slot]

This is an overloaded version for convenience.

See Also:
setBackgroundColor

void setFont(const QFont& font) [public slot]

Sets the font for the label.

void setText(const char* text) [public slot]

Sets the label contents to text

See Also:
text

void setPixmap(const QPixmap& pixmap) [public slot]

Sets the pixmap. Unlike QLabel, this can co-exist with setText It cannot be used along with setMovie however.

See Also:
pixmap

void setAltPixmap(const QPixmap& pixmap) [public 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' with javascript.

See Also:
KURLLabel::altPixmap

void setMovie(const QMovie& movie) [public slot]

Sets the movie. Cannot be used with setPixmap

See Also:
KURLLabel::movie

void setURL(const char* url) [public slot]

Sets the URL for this label to url

See Also:
url

void drawContents(QPainter *) [protected]

Draws the text, pixmap, and/or movie

void timerEvent(QTimerEvent *) [protected]

Used to "glow" the text when it is selected.

void m_enterEvent() [protected]

emits the enteredURL signal. If glow is on, it sets the selected color.

void m_leaveEvent() [protected]

emits the leftURL signal. If glow is on, it sets the normal color.

void leaveEvent(QEvent *event) [protected]

Processes "true" leave events since mouseMoveEvent cannot

void mouseMoveEvent(QMouseEvent *) [protected]

Tracks if the cursor is above the text as well as the mouse state. It emits either the enteredURL leftURL leftClickedURL middleClickedURL or rightClickedURL as appropriate.

void mousePressEvent(QMouseEvent *) [protected]

emits either the leftClickedURL rightClickedURL or middleClickedURL signal depending on which one the user clicked. Changes the color to selected to indicate that it was selected. Starts a timer to deselect it.

void paintEvent(QPaintEvent*) [protected]

An overloaded repaint event that handles the background in transparent mode. It sets a background pixmap that is obtained from the widgets parent and calls the QLabel repaint handler after that.

void enteredURL(const char* url) [signal]

The mouse has passed over the label.

Parameters:
url The URL for this label.

void enteredURL() [signal]

The mouse has passed over the label.

void leftURL(const char* url) [signal]

The mouse is no longer over the label.

Parameters:
url The URL for this label.

void leftURL() [signal]

The mouse is no longer over the label.

void leftClickedURL(const char* url) [signal]

The user clicked the left mouse button on this label.

Parameters:
url The URL for this label.

void leftClickedURL() [signal]

The user clicked the left mouse button on this label.

void rightClickedURL(const char* url) [signal]

The user clicked the right mouse button on this label.

Parameters:
url The URL for this label.

void rightClickedURL() [signal]

The user clicked the left mouse button on this label.

void middleClickedURL(const char* url) [signal]

The user clicked the middle mouse button on this label.

Parameters:
url The URL for this label.

void middleClickedURL() [signal]

The user clicked the left mouse button on this label.


  • Author: Kurt Granroth <granroth@kde.org>
  • Version: 0.5.3
  • Documentation generated by tasin@cd1 on Die Nov 30 17:31:44 CET 1999
Kdoc