Class 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#
typedef LinkHoverHandler#
Public Static Functions Documentation#
function activateLink#
Convenience helpers to invoke handlers manually.
function enableAutoWire#
Auto-wire ALL QLabel, QTextBrowser, and QTextEdit widgets in the app.
function hoverLink#
function install#
Install once; safe to call multiple times.
function setHoverHandler#
function setLinkHandler#
Set global handlers.
function setPointerCursorActive#
Public on purpose so helper filters can toggle cursor safely.
function setUseOverrideCursorOnLinks#
Optional: use a global pointing-hand cursor when hovering links anywhere.
function useOverrideCursorOnLinks#
Query whether override cursor mode is enabled.
function wireLabel#
Wire a single QLabel explicitly.
function wireTextBrowser#
Wire a single QTextBrowser explicitly.
function wireTextEdit#
Wire a single QTextEdit explicitly (adds a viewport event filter).