Web Analytics Made Easy - Statcounter
Skip to content

Class SBGUIHtmlFilter#

ClassList > SBGUIHtmlFilter

SBGUIHtmlFilter Lightweight, application-wide HTML link router for QLabel, QTextBrowser, and QTextEdit.More...

  • #include "SBGUIHtmlFilter.hpp"

Classes#

Type Name
class EventFilter

Public Types#

Type Name
typedef std::function< void(const QString &href)> LinkHandler
typedef std::function< void(const QString &href)> LinkHoverHandler

Public Static Functions#

Type Name
void activateLink (const QString & href)
Convenience helpers to invoke handlers manually.
void enableAutoWire (bool on=true)
Auto-wire ALL QLabel, QTextBrowser, and QTextEdit widgets in the app.
void hoverLink (const QString & href)
void install (QApplication * app=nullptr)
Install once; safe to call multiple times.
void setHoverHandler (LinkHoverHandler handler)
void setLinkHandler (LinkHandler handler)
Set global handlers.
void setPointerCursorActive (bool on)
Public on purpose so helper filters can toggle cursor safely.
void setUseOverrideCursorOnLinks (bool enable)
Optional: use a global pointing-hand cursor when hovering links anywhere.
bool useOverrideCursorOnLinks ()
Query whether override cursor mode is enabled.
void wireLabel (QLabel * label)
Wire a single QLabel explicitly.
void wireTextBrowser (QTextBrowser * browser)
Wire a single QTextBrowser explicitly.
void wireTextEdit (QTextEdit * edit)
Wire a single QTextEdit explicitly (adds a viewport event filter).

Detailed Description#

Features * Routes <a href="...">...</a> to global click/hover handlers * Auto-wires all QLabel/QTextBrowser/QTextEdit (optional), or wire individually * Optional global pointing-hand cursor on link hover

Notes * Per-widget opt-out: setProperty("sb_skip_autolink", true) * For QTextEdit, installs a viewport event filter and uses anchorAt() for hover/click.

Public Types Documentation#

typedef LinkHandler#

using SBGUIHtmlFilter::LinkHandler =  std::function<void(const QString& href)>;

typedef LinkHoverHandler#

using SBGUIHtmlFilter::LinkHoverHandler =  std::function<void(const QString& href)>;

Public Static Functions Documentation#

Convenience helpers to invoke handlers manually.

static void SBGUIHtmlFilter::activateLink (
    const QString & href
) 


function enableAutoWire#

Auto-wire ALL QLabel, QTextBrowser, and QTextEdit widgets in the app.

static void SBGUIHtmlFilter::enableAutoWire (
    bool on=true
) 


static void SBGUIHtmlFilter::hoverLink (
    const QString & href
) 

function install#

Install once; safe to call multiple times.

static void SBGUIHtmlFilter::install (
    QApplication * app=nullptr
) 


function setHoverHandler#

static void SBGUIHtmlFilter::setHoverHandler (
    LinkHoverHandler handler
) 

function setLinkHandler#

Set global handlers.

static void SBGUIHtmlFilter::setLinkHandler (
    LinkHandler handler
) 


function setPointerCursorActive#

Public on purpose so helper filters can toggle cursor safely.

static void SBGUIHtmlFilter::setPointerCursorActive (
    bool on
) 


Optional: use a global pointing-hand cursor when hovering links anywhere.

static void SBGUIHtmlFilter::setUseOverrideCursorOnLinks (
    bool enable
) 


Query whether override cursor mode is enabled.

static bool SBGUIHtmlFilter::useOverrideCursorOnLinks () 


function wireLabel#

Wire a single QLabel explicitly.

static void SBGUIHtmlFilter::wireLabel (
    QLabel * label
) 


function wireTextBrowser#

Wire a single QTextBrowser explicitly.

static void SBGUIHtmlFilter::wireTextBrowser (
    QTextBrowser * browser
) 


function wireTextEdit#

Wire a single QTextEdit explicitly (adds a viewport event filter).

static void SBGUIHtmlFilter::wireTextEdit (
    QTextEdit * edit
)