• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

KURLLabel Class Reference

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

#include <kurllabel.h>

Inheritance diagram for KURLLabel:

Inheritance graph
[legend]

List of all members.


Public Slots

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

Signals

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

Public Member Functions

const QPixmap * altPixmap () const
bool isFloatEnabled () const
bool isGlowEnabled () const
 KURLLabel (const QString &url, const QString &text=QString::null, QWidget *parent=0L, const char *name=0L)
 KURLLabel (QWidget *parent=0L, const char *name=0L)
virtual void setFocusPolicy (FocusPolicy policy)
virtual void setMargin (int margin)
virtual void setSizePolicy (QSizePolicy)
const QString & tipText () const
const QString & url () const
bool useCursor () const
bool useTips () const
virtual ~KURLLabel ()

Protected Member Functions

QRect activeRect () const
virtual void enterEvent (QEvent *)
virtual bool event (QEvent *e)
virtual void leaveEvent (QEvent *)
virtual void mouseReleaseEvent (QMouseEvent *e)
virtual void virtual_hook (int id, void *data)

Properties

QPixmap altPixmap
bool floatEnabled
bool glowEnabled
QString tipText
QString url
bool useCursor
bool useTips

Detailed Description

A drop-in replacement for QLabel that displays 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.

By default KURLLabel accepts focus. When focused, standard focus rectangle is displayed as in HTML widget. Pressing Enter key accepts the focused label.

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

KDE URL Label

Author:
Kurt Granroth <granroth@kde.org> (Interface)

Peter Putzer <putzer@kde.org> (Rewrite)

Version:
Id
kurllabel.h 504601 2006-02-01 14:15:28Z staniek

Definition at line 71 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.

Definition at line 94 of file kurllabel.cpp.

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 Passed to lower level constructor
name Passed to lower level constructor
parent and name are passed to QLabel, which in turn passes them further down

Definition at line 82 of file kurllabel.cpp.

KURLLabel::~KURLLabel (  )  [virtual]

Destructs the label.

Definition at line 105 of file kurllabel.cpp.


Member Function Documentation

QRect KURLLabel::activeRect (  )  const [protected]

Definition at line 405 of file kurllabel.cpp.

const QPixmap* KURLLabel::altPixmap (  )  const

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.

void KURLLabel::enterEvent ( QEvent *  e  )  [protected, virtual]

Overridden for internal reasons; the API remains unaffected.

Definition at line 306 of file kurllabel.cpp.

bool KURLLabel::event ( QEvent *  e  )  [protected, virtual]

Catch parent palette changes.

Definition at line 352 of file kurllabel.cpp.

bool KURLLabel::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.

Definition at line 291 of file kurllabel.cpp.

bool KURLLabel::isGlowEnabled (  )  const

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

Definition at line 286 of file kurllabel.cpp.

void KURLLabel::leaveEvent ( QEvent *  e  )  [protected, virtual]

Overridden for internal reasons; the API remains unaffected.

Definition at line 336 of file kurllabel.cpp.

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.

void KURLLabel::mouseReleaseEvent ( QMouseEvent *  e  )  [protected, virtual]

Overridden for internal reasons; the API remains unaffected.

Definition at line 110 of file kurllabel.cpp.

void KURLLabel::rightClickedURL (  )  [signal]

Emitted when the user clicked the right 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()

Definition at line 296 of file kurllabel.cpp.

void KURLLabel::setCursor ( const QCursor &  cursor  )  [virtual, slot]

Overridden for internal reasons; the API remains unaffected.

Definition at line 199 of file kurllabel.cpp.

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.

Definition at line 281 of file kurllabel.cpp.

void KURLLabel::setFocusPolicy ( FocusPolicy  policy  )  [virtual]

Reimplemented for internal reasons, the API is not affected.

Definition at line 431 of file kurllabel.cpp.

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

Overridden for internal reasons; the API remains unaffected.

Reimplemented from QLabel.

Definition at line 145 of file kurllabel.cpp.

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.

Definition at line 276 of file kurllabel.cpp.

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

This is an overloaded version for convenience.

See also:
setHighlightedColor()

Definition at line 258 of file kurllabel.cpp.

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

Sets the highlight color.

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

Definition at line 250 of file kurllabel.cpp.

void KURLLabel::setMargin ( int  margin  )  [virtual]

Reimplemented for internal reasons, the API is not affected.

Definition at line 425 of file kurllabel.cpp.

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

This is an overloaded version for convenience.

See also:
setSelectedColor()

Definition at line 271 of file kurllabel.cpp.

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.

Definition at line 263 of file kurllabel.cpp.

void KURLLabel::setSizePolicy ( QSizePolicy  policy  )  [virtual]

Reimplemented for internal reasons, the API is not affected.

Definition at line 439 of file kurllabel.cpp.

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()

Definition at line 233 of file kurllabel.cpp.

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.

Definition at line 153 of file kurllabel.cpp.

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

Sets the URL for this label to url.

See also:
url

Definition at line 178 of file kurllabel.cpp.

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

Definition at line 205 of file kurllabel.cpp.

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.

Definition at line 223 of file kurllabel.cpp.

const QString& KURLLabel::tipText (  )  const

Returns the current tooltip text.

void KURLLabel::unsetCursor (  )  [virtual, slot]

Overridden for internal reasons; the API remains unaffected.

Definition at line 193 of file kurllabel.cpp.

const QString& KURLLabel::url (  )  const

Returns the URL.

bool KURLLabel::useCursor (  )  const

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

bool KURLLabel::useTips (  )  const

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

void KURLLabel::virtual_hook ( int  id,
void *  data 
) [protected, virtual]

Definition at line 447 of file kurllabel.cpp.


Property Documentation

const QPixmap * KURLLabel::altPixmap [read, write]

Definition at line 76 of file kurllabel.h.

bool KURLLabel::floatEnabled [read, write]

Definition at line 78 of file kurllabel.h.

bool KURLLabel::glowEnabled [read, write]

Definition at line 77 of file kurllabel.h.

const QString & KURLLabel::tipText [read, write]

Definition at line 75 of file kurllabel.h.

const QString & KURLLabel::url [read, write]

Definition at line 74 of file kurllabel.h.

bool KURLLabel::useCursor [read, write]

Definition at line 80 of file kurllabel.h.

bool KURLLabel::useTips [read, write]

Definition at line 79 of file kurllabel.h.


The documentation for this class was generated from the following files:
  • kurllabel.h
  • kurllabel.cpp

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal