HusTourStep 漫游式引导

February 2, 2026 · View on GitHub

← 返回主目录

← 返回本类别目录

HusTourStep 漫游式引导

用于分步引导用户了解产品功能的气泡组件。

  • 模块 { HuskarUI.Basic }

  • 继承自 { Popup }


支持的代理:

  • arrowDelegate: Component 步骤箭头代理

  • closeButtonDelegate: Component 右上角关闭按钮代理

  • stepCardDelegate: Component 步骤卡片代理

  • indicatorDelegate: Component 步骤指示器代理


支持的属性:

属性名类型默认值描述
animationEnabledboolHusTheme.animationEnabled是否开启动画
penetrationEventboolfalse是否可穿透事件
closablebooltrue是否显示右上角的关闭按钮
maskClosableboolfalse点击蒙层是否允许关闭
stepModelarray[]步骤模型
currentTargetItemnull当前步骤目标
currentStepint0当前步数
overlayColorcolor-覆盖层颜色
showArrowbooltrue是否显示箭头
arrowWidthint16箭头宽度
arrowHeightint8箭头高度
focusMarginint5焦点边距
focusRadiusint2焦点圆角
stepCardWidthint250步骤卡片宽度
radiusStepCardHusRadius-步骤默认卡片半径
colorStepCardcolor-步骤默认卡片颜色
stepTitleFontfont-步骤默认标题字体
colorStepTitlecolor-步骤默认标题颜色
stepDescriptionFontfont-步骤默认描述字体
colorStepDescriptioncolor-步骤默认描述颜色
indicatorFontfont-步骤默认指示器字体
colorIndicatorcolor-步骤默认指示器颜色
buttonFontfont-步骤默认按钮字体

步骤对象支持的属性:

属性名类型可选/必选描述
targetItem必选本步骤指向目标
titlesting可选本步骤标题
titleColorcolor可选本步骤标题颜色
descriptionsting可选本步骤描述内容
descriptionColorcolor可选本步骤描述内容文本颜色
cardWidthint可选本步骤卡片宽度
cardHeightint可选本步骤卡片高度
cardColorcolor可选本步骤卡片颜色
cardRadiusint可选本步骤卡片圆角

支持的函数:

  • gotoStep(step: int) 跳转步骤

  • resetStep() 重置步骤

  • appendStep(object: Object) 添加步骤

    • object 步骤对象

代码演示

示例 1 - 基本

通过 currentTarget 属性获取当前步骤目标

通过 currentStep 属性获取当前步数

通过 overlayColor 属性设置覆盖层颜色

通过 stepModel 属性设置步骤模型{需为list},步骤项支持的属性有:

  • { target: 本步骤指向目标 }

  • { title: 本步骤标题 }

  • { titleColor: 本步骤标题颜色 }

  • { description: 本步骤描述内容 }

  • { descriptionColor: 本步骤描述内容文本颜色 }

  • { cardWidth: 本步骤卡片宽度 }

  • { cardHeight: 本步骤卡片高度 }

  • { cardColor: 本步骤卡片颜色 }

  • { cardRadius: 本步骤卡片圆角 }

import QtQuick
import HuskarUI.Basic

Column {
    spacing: 10

    HusButton {
        text: qsTr('漫游步骤')
        type: HusButton.Type_Primary
        onClicked: {
            tourStep.resetStep();
            tourStep.open();
        }

        HusTourStep {
            id: tourStep
            closable: closableRadio.currentCheckedValue
            stepModel: [
                {
                    target: tourStepButton1,
                    title: qsTr('步骤1'),
                    titleColor: '#3fcc9b',
                    description: qsTr('这是步骤1\n========'),
                },
                {
                    target: tourStepButton2,
                    title: qsTr('步骤2'),
                    description: qsTr('这是步骤2\n!!!!!!!!!!'),
                    descriptionColor: '#3116ff'
                },
                {
                    target: tourStep3Button,
                    cardColor: '#ffa2eb',
                    title: qsTr('步骤3'),
                    titleColor: 'red',
                    description: qsTr('这是步骤3\n##############')
                }
            ]
        }
    }

    Row {
        spacing: 10

        HusButton {
            id: tourStepButton1
            text: qsTr('漫游步骤1')
            type: HusButton.Type_Outlined
        }

        HusButton {
            id: tourStepButton2
            text: qsTr('漫游步骤2')
            type: HusButton.Type_Outlined
        }

        HusButton {
            id: tourStepButton3
            text: qsTr('漫游步骤3   ####')
            type: HusButton.Type_Outlined
        }
    }

    HusRadioBlock {
        id: closableRadio
        initCheckedIndex: 0
        model: [
            { label: 'Closable', value: true},
            { label: 'Non-closable', value: false }
        ]
    }
}

示例 2 - 自定义高亮区域的样式

通过 penetrationEvent 属性设置是否可穿透事件。

通过 focusMargin 属性设置高亮区域边距。

通过 focusRadius 属性设置高亮区域圆角。

通过 stepCardDelegate 属性自定义卡片。

import QtQuick
import HuskarUI.Basic

Column {
    spacing: 10

    HusButton {
        text: qsTr('开始漫游')
        type: HusButton.Type_Primary
        onClicked: {
            tourStep2.open();
        }

        HusTourStep {
            id: tourStep2
            penetrationEvent: true
            focusMargin: marginSlider.currentValue
            focusRadius: radiusSlider.currentValue
            stepModel: [{ target: tourStepGrid }]
            stepCardDelegate: Rectangle {
                id: __stepCardDelegate
                width: 520
                height: column2.height + 20
                color: tourStep2.colorStepCard
                radius: tourStep2.radiusStepCard

                property var stepData: tourStep2.stepModel[tourStep2.currentStep]

                Column {
                    id: column2
                    width: parent.width - 20
                    anchors.centerIn: parent
                    spacing: 10

                    HusCaptionButton {
                        anchors.right: parent.right
                        iconSource: HusIcon.CloseOutlined
                        onClicked: {
                            tourStep2.close();
                        }
                    }

                    Image {
                        width: parent.width
                        height: 120
                        source: 'https://user-images.githubusercontent.com/5378891/197385811-55df8480-7ff4-44bd-9d43-a7dade598d70.png'
                    }

                    HusText {
                        text: 'Upload File'
                        font.bold: true
                    }

                    HusText {
                        text: 'Put your files here.'
                    }

                    HusButton {
                        anchors.right: parent.right
                        text: qsTr('结束导览')
                        type: HusButton.Type_Primary
                        onClicked: {
                            tourStep2.close();
                        }
                    }
                }
            }
        }
    }

    Grid {
        id: tourStepGrid
        spacing: 10
        columns: 2
        verticalItemAlignment: Grid.AlignVCenter

        HusText {
            text: 'Margin: '
        }

        HusSlider {
            id: marginSlider
            width: 200
            height: 30
            min: 0
            max: 30
            value: 5
            handleToolTipDelegate: HusToolTip {
                visible: handleHovered || handlePressed
                text: marginSlider.currentValue.toFixed(0)
            }
        }

        HusText {
            text: 'Radius: '
        }

        HusSlider {
            id: radiusSlider
            width: 200
            height: 30
            min: 0
            max: 30
            handleToolTipDelegate: HusToolTip {
                visible: handleHovered || handlePressed
                text: radiusSlider.currentValue.toFixed(0)
            }
        }
    }
}