Fluent-Qt

基础能力

QML+:绑定、锚点与状态

为 QWidget 提供属性绑定、锚点和命名状态,不需要 QML 引擎。

绑定属性

bind() 让控件属性跟随源属性变化,源属性的通知信号触发时自动更新。需要暂停、恢复或解除绑定时,保留返回的 BindingHandle。

auto* slider = new fluent::basicinput::Slider(Qt::Horizontal, this);
slider->setRange(0, 100);
auto* bar = new fluent::status_info::ProgressBar(this);
bar->setRange(0, 100);
bar->bind("value", slider, "value");

锚点与状态

C++ 中 anchors() 返回控件的 AnchorLayout::Anchors,可以把边缘或中心线相对父控件或相邻控件定位,并设置偏移。addState() 和 addTransition() 用于成组切换属性并播放过渡动画。Python 中用 fluentqt.anchors() 描述锚点并把控件加入 AnchorLayout,状态由 StateGroup 提供。

#include <FluentQt/Foundation.h>

// badge is a child of card
using Edge = fluent::AnchorLayout::Edge;
badge->anchors()->top = {card, Edge::Top, 12};
badge->anchors()->right = {card, Edge::Right, -12};

API 参考