Text fields
DiffView
Syntax-highlighted Side-by-Side and Unified text diff viewer with inline word diffs, context folding, and hunk navigation.
Example
Property preview could not load. Select Property preview to retry.

Usage
Side-by-side and unified diff
Set both texts with setOriginalText() and setModifiedText(). Copied patches preserve final newlines. The summary marks approximate results when a large region exceeds the exact comparison budget.
#include <FluentQt/TextFields.h>
using namespace fluent::textfields;
auto* diff = new DiffView(this);
diff->setOriginalTitle("v1/Server.cpp");
diff->setModifiedTitle("v2/Server.cpp");
diff->setLanguage("cpp");
diff->setOriginalText(
"struct ServerConfig {\n"
" int timeoutSeconds = 30;\n"
" bool autoReconnect = false;\n"
"};\n"
"void startServer() { listen(8080); }");
diff->setModifiedText(
"struct ServerConfig {\n"
" int timeoutSeconds = 120;\n"
" bool autoReconnect = true;\n"
" int maxConnections = 64;\n"
"};\n"
"void startServer() { listen(8443); }");import fluentqt
diff = fluentqt.DiffView()
diff.setObjectName("sampleDiffView")
diff.setFixedSize(760, 210)
diff.setOriginalTitle("v1/Server.cpp")
diff.setModifiedTitle("v2/Server.cpp")
diff.setLanguage("cpp")
diff.setOriginalText(
"struct ServerConfig {\n"
" int timeoutSeconds = 30;\n"
" bool autoReconnect = false;\n"
"};\n"
"void startServer() { listen(8080); }"
)
diff.setModifiedText(
"struct ServerConfig {\n"
" int timeoutSeconds = 120;\n"
" bool autoReconnect = true;\n"
" int maxConnections = 64;\n"
"};\n"
"void startServer() { listen(8443); }"
)API
DeclarationNo matching API members.
fluent::textfields::DiffView
Inherits QWidget · FluentElement · QMLPlus
Fluent syntax-highlighted text diff viewer supporting Side-by-Side and Unified views with inline word diffs and hunk navigation.
Constructors
Properties
QString originalTextOriginal (baseline) text displayed for comparison.
ReadoriginalText()WritesetOriginalText()NotifyoriginalTextChanged()QString modifiedTextModified (updated) text displayed for comparison.
ReadmodifiedText()WritesetModifiedText()NotifymodifiedTextChanged()QString originalTitleHeader title identifying the original pane.
ReadoriginalTitle()WritesetOriginalTitle()NotifyoriginalTitleChanged()QString modifiedTitleHeader title identifying the modified pane.
ReadmodifiedTitle()WritesetModifiedTitle()NotifymodifiedTitleChanged()QString languageSyntax highlighting language. Changing it preserves the current hunk and scroll position.
Readlanguage()WritesetLanguage()NotifylanguageChanged()ViewMode viewModePresentation mode selecting side-by-side split panes or a unified stream.
ReadviewMode()WritesetViewMode()NotifyviewModeChanged()bool lineNumbersVisibleWhether line-number gutters are shown next to diff lines.
ReadisLineNumbersVisible()WritesetLineNumbersVisible()NotifylineNumbersVisibleChanged()bool wordDiffEnabledWhether changed word/token spans inside modified lines are emphasized inline.
ReadisWordDiffEnabled()WritesetWordDiffEnabled()NotifywordDiffEnabledChanged()int contextLinesNumber of unchanged context lines kept around each change hunk (-1 shows all lines).
ReadcontextLines()WritesetContextLines()NotifycontextLinesChanged()int addedLineCountTotal added line count in the current diff.
ReadaddedLineCount()NotifydiffComputed()int removedLineCountTotal removed line count in the current diff.
ReadremovedLineCount()NotifydiffComputed()int hunkCountTotal contiguous change hunk count.
ReadhunkCount()NotifydiffComputed()int currentHunkIndexZero-based index of the currently focused hunk, or -1 when no hunks exist.
ReadcurrentHunkIndex()NotifycurrentHunkChanged()
Methods
QString originalText() constOriginal (baseline) text displayed for comparison.
void setOriginalText(const QString& text)Original (baseline) text displayed for comparison.
QString modifiedText() constModified (updated) text displayed for comparison.
void setModifiedText(const QString& text)Modified (updated) text displayed for comparison.
QString originalTitle() constHeader title identifying the original pane.
void setOriginalTitle(const QString& title)Header title identifying the original pane.
QString modifiedTitle() constHeader title identifying the modified pane.
void setModifiedTitle(const QString& title)Header title identifying the modified pane.
QString language() constSyntax highlighting language. Changing it preserves the current hunk and scroll position.
void setLanguage(const QString& language)Syntax highlighting language. Changing it preserves the current hunk and scroll position.
ViewMode viewMode() constPresentation mode selecting side-by-side split panes or a unified stream.
void setViewMode(ViewMode mode)Presentation mode selecting side-by-side split panes or a unified stream.
bool isLineNumbersVisible() constWhether line-number gutters are shown next to diff lines.
void setLineNumbersVisible(bool visible)Whether line-number gutters are shown next to diff lines.
bool isWordDiffEnabled() constWhether changed word/token spans inside modified lines are emphasized inline.
void setWordDiffEnabled(bool enabled)Whether changed word/token spans inside modified lines are emphasized inline.
int contextLines() constNumber of unchanged context lines kept around each change hunk (-1 shows all lines).
void setContextLines(int lines)Number of unchanged context lines kept around each change hunk (-1 shows all lines).
int addedLineCount() constTotal added line count in the current diff.
int removedLineCount() constTotal removed line count in the current diff.
int hunkCount() constTotal contiguous change hunk count.
int currentHunkIndex() constZero-based index of the currently focused hunk, or -1 when no hunks exist.
bool isUnified() constReturns true when viewMode is ViewMode::Unified.
bool jumpToNextHunk()Scrolls to and activates the next change hunk (wrapping around).
bool jumpToPreviousHunk()Scrolls to and activates the previous change hunk (wrapping around).
bool jumpToHunk(int index)Scrolls to and activates the change hunk at @p index.
void copyUnifiedPatch()Copies a standard unified diff patch representation to the system clipboard.
QString unifiedPatch() constFormats the current diff as a unified diff patch string.
int visibleRowCount() constReturns the number of rendered rows in the active presentation mode (excluding folded filler details).
Signals
void originalTextChanged(const QString& text)Original (baseline) text displayed for comparison.
void modifiedTextChanged(const QString& text)Modified (updated) text displayed for comparison.
void originalTitleChanged(const QString& title)Header title identifying the original pane.
void modifiedTitleChanged(const QString& title)Header title identifying the modified pane.
void languageChanged(const QString& language)Syntax highlighting language. Changing it preserves the current hunk and scroll position.
void viewModeChanged(ViewMode viewMode)Presentation mode selecting side-by-side split panes or a unified stream.
void lineNumbersVisibleChanged(bool visible)Whether line-number gutters are shown next to diff lines.
void wordDiffEnabledChanged(bool enabled)Whether changed word/token spans inside modified lines are emphasized inline.
void contextLinesChanged(int contextLines)Number of unchanged context lines kept around each change hunk (-1 shows all lines).
void diffComputed(int addedLines, int removedLines, int hunks)Total added line count in the current diff.
void currentHunkChanged(int currentHunkIndex)Zero-based index of the currently focused hunk, or -1 when no hunks exist.
Enumerations
enum class ViewModeDiff presentation layout mode.
SideBySide = 0Unified = 1
enum class LineKindSemantic role of an individual diff line slot.
Context = 0Added = 1Removed = 2Modified = 3Empty = 4
Destructors
Protected members
Methods
Inherited from fluent::FluentElement
Methods
static void setTheme(Theme theme)Updates the global theme and notifies active FluentElement instances.
static void setThemeDeferred(Theme theme)Schedules a visible-first batched theme refresh without blocking the current interaction.
static Theme currentTheme()Returns the currently active global theme.
static bool themeUsesDarkAppearance(Theme theme)Returns whether a theme uses dark-backed chrome and material tokens.
static void refreshTheme()Re-broadcasts the current theme to repaint after a design-token change.
static int themeGeneration()Monotonic counter bumped on every theme change, for staleness checks.
Theme effectiveTheme() constResolves the theme used by this element, honoring an inherited QWidget override.
bool effectiveThemeUsesDarkAppearance() constReturns whether this element's effective theme uses dark-backed chrome.
bool setThemeOverrides(const QJsonObject& overrides)Replaces this element's sparse color, radius, and font token overrides.
QJsonObject themeOverrides() constReturns this element's authored overrides.
void clearThemeOverrides()Restores all token fields to global theme defaults.
const Colors& themeColorsRef() constNon-copying access to the active color set for hot paint paths.
Material::AcrylicToken themeAcrylic() constMaterial, elevation, and adaptive layout tokens.
QColor themeBackdrop(bool active) constWindow-chrome backdrop color for the given activation state.
virtual void onThemeUpdated()Called after the global theme changes.
Enumerations
enum ThemeGlobal visual theme used when resolving design tokens.
Light = 0Dark = 1HighContrast = 2
Types and aliases
struct ColorsDesign token snapshots returned to components.
Inherited from fluent::QMLPlus
Methods
AnchorLayout::Anchors* anchors()Returns mutable anchors for the QWidget host.
void setState(const QString& name)Applies a registered state by name, or restores the default state when @p name is empty. Unknown names are ignored, and existing bindings resume when leaving the state.
void addState(const QMLState& state)Registers or replaces a named state definition; replacing the active state applies it immediately.
void evaluateStates()Reevaluates state conditions in registration order and activates the first match, or the default state if none match. Also runs automatically when dependency properties notify; derived states using extend inherit ancestor changes unless cyclic or missing.
QMLPlusRuntime* runtime()Returns the lazily created state observer owned by this host.
void setAnchors(const AnchorLayout::Anchors& anchors)Replaces all host anchors and invalidates the parent layout.
void resetAnchors()Clears all host anchors and invalidates the parent layout.
void bind(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction dir = PropertyBinder::OneWay)Binds @p sourceProp on @p source to @p targetProp on this QWidget host via PropertyBinder::bind().
BindingHandle bindManaged(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction direction = PropertyBinder::OneWay, BindingOptions options = {})Installs a managed direct binding on this QWidget host.
BindingHandle bindComputed(const char* targetProp, const QVector<BindingDependency>& dependencies, std::function<QVariant()> evaluate, BindingOptions options = {})Installs an explicit-dependency C++ expression on this QWidget host.
void addTransition(const StateTransition& transition)Registers a state transition in precedence order.
void setBehavior(const char* propertyName, const PropertyAnimation& animation)Sets the default animation used when @p propertyName is written via writeProperty() or a binding. Explicit StateTransition rules take precedence; direct C++ setter calls are not animated.
void clearBehavior(const char* propertyName)Removes the default animation for future managed writes.
bool writeProperty(const char* propertyName, const QVariant& value)Writes a host property through Behavior without removing its binding.
Qt base class docs: QWidget