# class KUrlLabel

###

Module | kdeui
Namespace |
Class | KUrlLabel
Inherits | QLabel

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.

Author Kurt Granroth <granroth@kde.org> (Interface) Author Peter Putzer <putzer@kde.org> (Rewrite)

### methods

- KUrlLabel (parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  parent | QWidget | 0

  Default constructor.

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

- KUrlLabel (url, text, parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  url | QString |
  text | QString | QString()
  parent | QWidget | 0

  Convenience constructor.

  url - is the URL emitted when the label is clicked.

  text - is the displayed string. If it's equal to QString() the url will be used instead.

  parent - Passed to lower level constructor

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

- KUrlLabel (a0)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QWidget | 0

- KUrlLabel (a0, a1, a2)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QString |
  a1 | QString | QString()
  a2 | QWidget | 0

- alternatePixmap ( )

  returns QPixmap

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

- enterEvent (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QEvent |

  Overridden for internal reasons; the API remains unaffected.

- enteredUrl (url)

  returns Nothing
  SIGNAL ("enteredUrl (const QString&)")

  Argument | Type | Default
  --- | --- | ---
  url | QString |

  Emitted when the mouse has passed over the label.

  url - The URL for this label.

- enteredUrl ( )

  returns Nothing
  SIGNAL ("enteredUrl ()")

  Emitted when the mouse has passed over the label.

- event (a0)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  a0 | QEvent |

  Catch parent palette changes

- isFloatEnabled ( )

  returns bool

  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.

- isGlowEnabled ( )

  returns bool

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

- leaveEvent (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QEvent |

  Overridden for internal reasons; the API remains unaffected.

- leftClickedUrl (url)

  returns Nothing
  SIGNAL ("leftClickedUrl (const QString&)")

  Argument | Type | Default
  --- | --- | ---
  url | QString |

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

  url - The URL for this label.

- leftClickedUrl ( )

  returns Nothing
  SIGNAL ("leftClickedUrl ()")

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

- leftUrl (url)

  returns Nothing
  SIGNAL ("leftUrl (const QString&)")

  Argument | Type | Default
  --- | --- | ---
  url | QString |

  Emitted when the mouse is no longer over the label.

  url - The URL for this label.

- leftUrl ( )

  returns Nothing
  SIGNAL ("leftUrl ()")

  Emitted when the mouse is no longer over the label.

- middleClickedUrl (url)

  returns Nothing
  SIGNAL ("middleClickedUrl (const QString&)")

  Argument | Type | Default
  --- | --- | ---
  url | QString |

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

  url - The URL for this label.

- middleClickedUrl ( )

  returns Nothing
  SIGNAL ("middleClickedUrl ()")

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

- mouseReleaseEvent (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QMouseEvent |

  Overridden for internal reasons; the API remains unaffected.

- rightClickedUrl (url)

  returns Nothing
  SIGNAL ("rightClickedUrl (const QString&)")

  Argument | Type | Default
  --- | --- | ---
  url | QString |

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

  url - The URL for this label.

- rightClickedUrl ( )

  returns Nothing
  SIGNAL ("rightClickedUrl ()")

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

- setAlternatePixmap (pixmap)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  pixmap | QPixmap |

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

- setFloatEnabled (do_float)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  do_float | bool | 1

  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.

- setFont (font)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  font | QFont |

  Overridden for internal reasons; the API remains unaffected.

- setGlowEnabled (glow)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  glow | bool | 1

  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.

- setHighlightedColor (highcolor)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  highcolor | QColor |

  Sets the highlight color.

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

- setHighlightedColor (highcolor)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  highcolor | QString |

  This is an overloaded version for convenience.

  See also setHighlightedColor()

- setSelectedColor (color)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  color | QColor |

  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.

- setSelectedColor (color)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  color | QString |

  This is an overloaded version for convenience.

  See also setSelectedColor()

- setTipText (tip)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  tip | QString |

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

- setUnderline (on)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  on | bool | 1

  Turns on or off the underlining.

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

- setUrl (url)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  url | QString |

  Sets the URL for this label to url.

  See also url

- setUseCursor (on, cursor)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  on | bool |
  cursor | QCursor | 0

  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.

  on - whether a custom cursor should be displayed.

  cursor - is the custom cursor. 0 indicates the default "hand cursor".

- setUseTips (on)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  on | bool | 1

  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.

- tipText ( )

  returns QString

  Returns the current tooltip text.

- url ( )

  returns QString

  Returns the URL.

- useCursor ( )

  returns bool

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

  See also setUseCursor ()

- useTips ( )

  returns bool

  Returns true if a tooltip will be displayed.

  See also setTipText()