• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
KUrlLabel Class Reference

#include <kurllabel.h>

Inheritance diagram for KUrlLabel:
Inheritance graph
[legend]

Public Slots

void setAlternatePixmap (const QPixmap &pixmap)
 
void setFloatEnabled (bool do_float=true)
 
virtual void setFont (const QFont &font)
 
void setGlowEnabled (bool glow=true)
 
void setHighlightedColor (const QColor &highcolor)
 
void setHighlightedColor (const QString &highcolor)
 
void setSelectedColor (const QColor &color)
 
void setSelectedColor (const QString &color)
 
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)
 

Signals

void enteredUrl (const QString &url)
 
void enteredUrl ()
 
void leftClickedUrl (const QString &url)
 
void leftClickedUrl ()
 
void leftUrl (const QString &url)
 
void leftUrl ()
 
void middleClickedUrl (const QString &url)
 
void middleClickedUrl ()
 
void rightClickedUrl (const QString &url)
 
void rightClickedUrl ()
 

Public Member Functions

 KUrlLabel (QWidget *parent=0L)
 
 KUrlLabel (const QString &url, const QString &text=QString(), QWidget *parent=0L)
 
virtual ~KUrlLabel ()
 
const QPixmap * alternatePixmap () const
 
bool isFloatEnabled () const
 
bool isGlowEnabled () const
 
QString tipText () const
 
QString url () const
 
bool useCursor () const
 
bool useTips () const
 

Protected Member Functions

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

Properties

QPixmap alternatePixmap
 
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 granr.nosp@m.oth@.nosp@m.kde.o.nosp@m.rg (Interface)
Peter Putzer putze.nosp@m.r@kd.nosp@m.e.org (Rewrite)

Definition at line 69 of file kurllabel.h.

Constructor & Destructor Documentation

KUrlLabel::KUrlLabel ( QWidget *  parent = 0L)
explicit

Default constructor.

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

Definition at line 97 of file kurllabel.cpp.

KUrlLabel::KUrlLabel ( const QString &  url,
const QString &  text = QString(),
QWidget *  parent = 0L 
)
explicit

Convenience constructor.

Parameters
urlis the URL emitted when the label is clicked.
textis the displayed string. If it's equal to QString() the url will be used instead.
parentPassed to lower level constructor

parent and name are passed to QLabel, which in turn passes them further down

Definition at line 88 of file kurllabel.cpp.

KUrlLabel::~KUrlLabel ( )
virtual

Destructs the label.

Definition at line 106 of file kurllabel.cpp.

Member Function Documentation

const QPixmap* KUrlLabel::alternatePixmap ( ) const
Returns
the alternate pixmap (may be 0L if none was set).
void KUrlLabel::enteredUrl ( const QString &  url)
signal

Emitted when the mouse has passed over the label.

Parameters
urlThe URL for this label.
void KUrlLabel::enteredUrl ( )
signal

Emitted when the mouse has passed over the label.

void KUrlLabel::enterEvent ( QEvent *  event)
protectedvirtual

Overridden for internal reasons; the API remains unaffected.

Definition at line 272 of file kurllabel.cpp.

bool KUrlLabel::event ( QEvent *  event)
protectedvirtual

Catch parent palette changes.

Use parentWidget() unless you are a toplevel widget, then try qAapp

Definition at line 312 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 257 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 252 of file kurllabel.cpp.

void KUrlLabel::leaveEvent ( QEvent *  event)
protectedvirtual

Overridden for internal reasons; the API remains unaffected.

Definition at line 296 of file kurllabel.cpp.

void KUrlLabel::leftClickedUrl ( const QString &  url)
signal

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

Parameters
urlThe URL for this label.
void KUrlLabel::leftClickedUrl ( )
signal

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

void KUrlLabel::leftUrl ( const QString &  url)
signal

Emitted when the mouse is no longer over the label.

Parameters
urlThe URL for this label.
void KUrlLabel::leftUrl ( )
signal

Emitted when the mouse is no longer over the label.

void KUrlLabel::middleClickedUrl ( const QString &  url)
signal

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

Parameters
urlThe URL for this label.
void KUrlLabel::middleClickedUrl ( )
signal

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

void KUrlLabel::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual

Overridden for internal reasons; the API remains unaffected.

Definition at line 111 of file kurllabel.cpp.

void KUrlLabel::rightClickedUrl ( const QString &  url)
signal

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

Parameters
urlThe URL for this label.
void KUrlLabel::rightClickedUrl ( )
signal

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

void KUrlLabel::setAlternatePixmap ( const QPixmap &  pixmap)
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
alternatePixmap()

Definition at line 262 of file kurllabel.cpp.

void KUrlLabel::setFloatEnabled ( 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 247 of file kurllabel.cpp.

void KUrlLabel::setFont ( const QFont &  font)
virtualslot

Overridden for internal reasons; the API remains unaffected.

Definition at line 139 of file kurllabel.cpp.

void KUrlLabel::setGlowEnabled ( 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 242 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 216 of file kurllabel.cpp.

void KUrlLabel::setHighlightedColor ( const QString &  highcolor)
slot

This is an overloaded version for convenience.

See also
setHighlightedColor()

Definition at line 224 of file kurllabel.cpp.

void KUrlLabel::setSelectedColor ( const QColor &  color)
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 229 of file kurllabel.cpp.

void KUrlLabel::setSelectedColor ( const QString &  color)
slot

This is an overloaded version for convenience.

See also
setSelectedColor()

Definition at line 237 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 199 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 147 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 154 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
onwhether a custom cursor should be displayed.
cursoris the custom cursor. 0L indicates the default "hand cursor".

Definition at line 169 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 189 of file kurllabel.cpp.

QString KUrlLabel::tipText ( ) const

Returns the current tooltip text.

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

Property Documentation

const QPixmap * KUrlLabel::alternatePixmap
readwrite

Definition at line 74 of file kurllabel.h.

bool KUrlLabel::floatEnabled
readwrite

Definition at line 76 of file kurllabel.h.

bool KUrlLabel::glowEnabled
readwrite

Definition at line 75 of file kurllabel.h.

QString KUrlLabel::tipText
readwrite

Definition at line 73 of file kurllabel.h.

QString KUrlLabel::url
readwrite

Definition at line 72 of file kurllabel.h.

bool KUrlLabel::useCursor
readwrite

Definition at line 78 of file kurllabel.h.

bool KUrlLabel::useTips
readwrite

Definition at line 77 of file kurllabel.h.


The documentation for this class was generated from the following files:
  • kurllabel.h
  • kurllabel.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal