QML
← 전체 컴포넌트

Collapse

콘텐츠를 접고 펼칠 수 있는 구역으로 나눕니다. 자주 묻는 질문이나 상세 설정을 정리할 때 사용합니다.

import Syidax.Core.Collapse

지원 QML 타입

타입정의 / 역할
여러 SyCollapsePanel의 펼침 상태를 관리하는 컨테이너입니다.
클릭 가능한 제목과 접고 펼치는 본문을 가진 섹션입니다.

예제로 보기

미리보기는 Qt 실행 화면의 이미지입니다. 아래 버튼으로 결과를 전환하세요.

01 기본 구성

SyCollapse는 SyCollapsePanel 구역을 쌓습니다: 각 구역은 안에 선언한 내용을 접는 40 px 헤더입니다.

Qt 실행 화면 · 이미지
기본 구성 · 기본
기본 실행 화면
QML 코드
import QtQuick
import Syidax.Core

Item {
    implicitWidth: Math.max(360, childrenRect.width)
    implicitHeight: childrenRect.height

    property QtObject settings: QtObject {
        id: storyArgs
        property bool accordion: false
        property bool borderless: false
        property bool ghost: false
        property bool disabled: false
        property bool arrow: false
    }

    readonly property string arrowProp: storyArgs.arrow ? "; arrow: true" : ""
    readonly property string members: [
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("배송") + "; active: true" + arrowProp,
        "    Text { text: " + JSON.stringify("주문은 영업일 기준 2일 안에 발송됩니다.") + " }",
        "}",
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("반품") + arrowProp,
        "    Text { text: " + JSON.stringify("30일 안에 반품할 수 있습니다.") + " }",
        "}",
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("결제") + arrowProp,
        "    Text { text: " + JSON.stringify("카드와 계좌 이체.") + " }",
        "}"
    ].join("\n")

    SyCollapse {
        accordion: storyArgs.accordion
        borderless: storyArgs.borderless
        ghost: storyArgs.ghost
        disabled: storyArgs.disabled
        SyCollapsePanel {
            title: "배송"; active: true; arrow: storyArgs.arrow
            Text { text: "주문은 영업일 기준 2일 안에 발송됩니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
        SyCollapsePanel {
            title: "반품"; arrow: storyArgs.arrow
            Text { text: "30일 안에 반품할 수 있습니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
        SyCollapsePanel {
            title: "결제"; arrow: storyArgs.arrow
            Text { text: "카드와 계좌 이체."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
    }

}

02 active · arrow · disabled · ghost

패널별: active: true는 처음부터 열어 둡니다(조용히 — changed 없음; 아코디언 스택에서는 미리 설정한 active가 다른 패널을 닫지 않으므로 하나만 active로 선언하십시오).

Qt 실행 화면 · 이미지
active · arrow · disabled · ghost · 기본
기본 실행 화면
QML 코드
import QtQuick
import Syidax.Core

Item {
    implicitWidth: Math.max(360, childrenRect.width)
    implicitHeight: childrenRect.height
    // Focused Gallery routes: keep only the selected API and its prerequisites.
    id: featureStory

    SyCollapse {
        width: 420
        SyCollapsePanel { id: featureTarget0; title: "처음부터 열림"; active: true; Text { text: "주문은 영업일 기준 2일 안에 발송됩니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault } }
        SyCollapsePanel { id: featureTarget1; title: "셰브론 왼쪽"; arrow: true; Text { text: "30일 안에 반품할 수 있습니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault } }
        SyCollapsePanel { id: featureTarget2; title: "비활성"; disabled: true; Text { text: "카드와 계좌 이체."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault } }
        SyCollapsePanel { id: featureTarget3; title: "고스트"; ghost: true; Text { text: "카드와 계좌 이체."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault } }
    }
}

03 changed

모든 SyCollapsePanel은 열리거나(true) 닫힐 때(false) changed(detail), detail = { active: bool }을 발생시킵니다

Qt 실행 화면 · 이미지
changed · 기본
기본 실행 화면
QML 코드
import QtQuick
import Syidax.Core

Item {
    component EventLog: Rectangle {
        id: logBox
        property var lines: []
        implicitWidth: 440
        implicitHeight: Math.max(56, logText.implicitHeight + 24)
        radius: 4; color: Theme.semantic.backgroundBold
        function log(value) { lines = lines.slice(-3).concat([String(value)]) }
        Text {
            id: logText; x: 12; y: 12; width: parent.width - 24
            text: logBox.lines.length ? logBox.lines.join("\n") : "컨트롤을 조작하면 이벤트 결과가 표시됩니다."
            wrapMode: Text.Wrap; color: Theme.semantic.textDefault
            font.family: Theme.monoFontFamily; font.pixelSize: 12
        }
    }

    implicitWidth: Math.max(360, childrenRect.width)
    implicitHeight: childrenRect.height

    

    Column {
        spacing: 12
        SyCollapse {
            width: 420
            SyCollapsePanel {
                id: shipping
                title: "배송"
                onChanged: (detail) => output.log(("%1 changed: %2").arg(shipping.title).arg(detail.active))
                Text { text: "주문은 영업일 기준 2일 안에 발송됩니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
            }
            SyCollapsePanel {
                id: returns
                title: "반품"
                onChanged: (detail) => output.log(("%1 changed: %2").arg(returns.title).arg(detail.active))
                Text { text: "30일 안에 반품할 수 있습니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
            }
        }
        EventLog { id: output }
    }
}

04 openAll · closeAll · openPanel · closePanel · toggle

스택에서: openAll()은 모든 패널을 엽니다(accordion이 켜져 있으면 통째로 무시).

Qt 실행 화면 · 이미지
openAll · closeAll · openPanel · closePanel · toggle · 기본
QML 코드
import QtQuick
import Syidax.Core

Item {
    implicitWidth: Math.max(360, childrenRect.width)
    implicitHeight: childrenRect.height
    // Focused Gallery routes: keep only the selected API and its prerequisites.
    id: featureStory

    Column {
        spacing: 24
        SyCollapse {
            id: faq
            width: 420
            SyCollapsePanel { id: first; title: "배송"; Text { text: "주문은 영업일 기준 2일 안에 발송됩니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault } }
            SyCollapsePanel { id: second; title: "반품"; Text { text: "30일 안에 반품할 수 있습니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault } }
        }
        Flow {
            width: 460
            spacing: 8
            SyButton { id: exampleControl1;  visible: true; text: "faq.openAll()"; variant: "secondary"; size: "small"; onClicked: faq.openAll() }
            SyButton { id: exampleControl2;  visible: true; text: "faq.closeAll()"; variant: "secondary"; size: "small"; onClicked: faq.closeAll() }
            SyButton { id: exampleControl3;  visible: true; text: "faq.openPanel(0)"; variant: "secondary"; size: "small"; onClicked: faq.openPanel(0) }
            SyButton { visible: true; text: "faq.closePanel(0)"; variant: "secondary"; size: "small"; onClicked: faq.closePanel(0) }
            SyButton { visible: true; text: "second.toggle()"; variant: "secondary"; size: "small"; onClicked: second.toggle() }
        }
        Text {
            text: "first.active === " + first.active + "   second.active === " + second.active
            font.family: Theme.monoFontFamily
            font.pixelSize: 12
            color: Theme.semantic.textSubtle
        }
    }
}

05 하나씩 펼치는 패널

accordion 설정을 적용한 하나씩 펼치는 패널 예제입니다.

Qt 실행 화면 · 이미지
하나씩 펼치는 패널 · 실행 결과
기본 실행 화면
QML 코드
import QtQuick
import Syidax.Core

Item {
    implicitWidth: Math.max(360, childrenRect.width)
    implicitHeight: childrenRect.height

    property QtObject settings: QtObject {
        id: storyArgs
        property bool accordion: true
        property bool borderless: false
        property bool ghost: false
        property bool disabled: false
        property bool arrow: false
    }

    readonly property string arrowProp: storyArgs.arrow ? "; arrow: true" : ""
    readonly property string members: [
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("배송") + "; active: true" + arrowProp,
        "    Text { text: " + JSON.stringify("주문은 영업일 기준 2일 안에 발송됩니다.") + " }",
        "}",
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("반품") + arrowProp,
        "    Text { text: " + JSON.stringify("30일 안에 반품할 수 있습니다.") + " }",
        "}",
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("결제") + arrowProp,
        "    Text { text: " + JSON.stringify("카드와 계좌 이체.") + " }",
        "}"
    ].join("\n")

    SyCollapse {
        accordion: storyArgs.accordion
        borderless: storyArgs.borderless
        ghost: storyArgs.ghost
        disabled: storyArgs.disabled
        SyCollapsePanel {
            title: "배송"; active: true; arrow: storyArgs.arrow
            Text { text: "주문은 영업일 기준 2일 안에 발송됩니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
        SyCollapsePanel {
            title: "반품"; arrow: storyArgs.arrow
            Text { text: "30일 안에 반품할 수 있습니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
        SyCollapsePanel {
            title: "결제"; arrow: storyArgs.arrow
            Text { text: "카드와 계좌 이체."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
    }

}

06 배경 없는 패널

ghost 설정을 적용한 배경 없는 패널 예제입니다.

Qt 실행 화면 · 이미지
배경 없는 패널 · 실행 결과
기본 실행 화면
QML 코드
import QtQuick
import Syidax.Core

Item {
    implicitWidth: Math.max(360, childrenRect.width)
    implicitHeight: childrenRect.height

    property QtObject settings: QtObject {
        id: storyArgs
        property bool accordion: false
        property bool borderless: false
        property bool ghost: true
        property bool disabled: false
        property bool arrow: false
    }

    readonly property string arrowProp: storyArgs.arrow ? "; arrow: true" : ""
    readonly property string members: [
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("배송") + "; active: true" + arrowProp,
        "    Text { text: " + JSON.stringify("주문은 영업일 기준 2일 안에 발송됩니다.") + " }",
        "}",
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("반품") + arrowProp,
        "    Text { text: " + JSON.stringify("30일 안에 반품할 수 있습니다.") + " }",
        "}",
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("결제") + arrowProp,
        "    Text { text: " + JSON.stringify("카드와 계좌 이체.") + " }",
        "}"
    ].join("\n")

    SyCollapse {
        accordion: storyArgs.accordion
        borderless: storyArgs.borderless
        ghost: storyArgs.ghost
        disabled: storyArgs.disabled
        SyCollapsePanel {
            title: "배송"; active: true; arrow: storyArgs.arrow
            Text { text: "주문은 영업일 기준 2일 안에 발송됩니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
        SyCollapsePanel {
            title: "반품"; arrow: storyArgs.arrow
            Text { text: "30일 안에 반품할 수 있습니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
        SyCollapsePanel {
            title: "결제"; arrow: storyArgs.arrow
            Text { text: "카드와 계좌 이체."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
    }

}

07 테두리 없는 패널

borderless 설정을 적용한 테두리 없는 패널 예제입니다.

Qt 실행 화면 · 이미지
테두리 없는 패널 · 실행 결과
기본 실행 화면
QML 코드
import QtQuick
import Syidax.Core

Item {
    implicitWidth: Math.max(360, childrenRect.width)
    implicitHeight: childrenRect.height

    property QtObject settings: QtObject {
        id: storyArgs
        property bool accordion: false
        property bool borderless: true
        property bool ghost: false
        property bool disabled: false
        property bool arrow: false
    }

    readonly property string arrowProp: storyArgs.arrow ? "; arrow: true" : ""
    readonly property string members: [
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("배송") + "; active: true" + arrowProp,
        "    Text { text: " + JSON.stringify("주문은 영업일 기준 2일 안에 발송됩니다.") + " }",
        "}",
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("반품") + arrowProp,
        "    Text { text: " + JSON.stringify("30일 안에 반품할 수 있습니다.") + " }",
        "}",
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("결제") + arrowProp,
        "    Text { text: " + JSON.stringify("카드와 계좌 이체.") + " }",
        "}"
    ].join("\n")

    SyCollapse {
        accordion: storyArgs.accordion
        borderless: storyArgs.borderless
        ghost: storyArgs.ghost
        disabled: storyArgs.disabled
        SyCollapsePanel {
            title: "배송"; active: true; arrow: storyArgs.arrow
            Text { text: "주문은 영업일 기준 2일 안에 발송됩니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
        SyCollapsePanel {
            title: "반품"; arrow: storyArgs.arrow
            Text { text: "30일 안에 반품할 수 있습니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
        SyCollapsePanel {
            title: "결제"; arrow: storyArgs.arrow
            Text { text: "카드와 계좌 이체."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
    }

}

08 비활성 패널

disabled 설정을 적용한 비활성 패널 예제입니다.

Qt 실행 화면 · 이미지
비활성 패널 · 실행 결과
기본 실행 화면
QML 코드
import QtQuick
import Syidax.Core

Item {
    implicitWidth: Math.max(360, childrenRect.width)
    implicitHeight: childrenRect.height

    property QtObject settings: QtObject {
        id: storyArgs
        property bool accordion: false
        property bool borderless: false
        property bool ghost: false
        property bool disabled: true
        property bool arrow: false
    }

    readonly property string arrowProp: storyArgs.arrow ? "; arrow: true" : ""
    readonly property string members: [
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("배송") + "; active: true" + arrowProp,
        "    Text { text: " + JSON.stringify("주문은 영업일 기준 2일 안에 발송됩니다.") + " }",
        "}",
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("반품") + arrowProp,
        "    Text { text: " + JSON.stringify("30일 안에 반품할 수 있습니다.") + " }",
        "}",
        "SyCollapsePanel {",
        "    title: " + JSON.stringify("결제") + arrowProp,
        "    Text { text: " + JSON.stringify("카드와 계좌 이체.") + " }",
        "}"
    ].join("\n")

    SyCollapse {
        accordion: storyArgs.accordion
        borderless: storyArgs.borderless
        ghost: storyArgs.ghost
        disabled: storyArgs.disabled
        SyCollapsePanel {
            title: "배송"; active: true; arrow: storyArgs.arrow
            Text { text: "주문은 영업일 기준 2일 안에 발송됩니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
        SyCollapsePanel {
            title: "반품"; arrow: storyArgs.arrow
            Text { text: "30일 안에 반품할 수 있습니다."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
        SyCollapsePanel {
            title: "결제"; arrow: storyArgs.arrow
            Text { text: "카드와 계좌 이체."; width: parent.width; wrapMode: Text.Wrap; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.semantic.textDefault }
        }
    }

}

API 54

항목을 가리키거나 선택하면 QML 예제와 복사 버튼이 나타납니다.

속성 · SyCollapse

속성타입기본값설명
list (기본 속성)—안에 선언한 패널, 순서대로
boolfalse한 번에 하나만 열림: 하나를 열면 나머지가 닫힘; openAll() 무시
boolfalse패널에 테두리 없음(배경은 유지)
boolfalse모든 패널에 테두리와 배경 없음
boolfalse모든 헤더 멈춤
boolfalse모든 패널에 적용(각 패널의 effectiveFullheight = 자기 것 또는 스택의 것)
var[]수집된 패널 — panels()를 읽으십시오

속성 · SyCollapsePanel

속성타입기본값설명
list (기본 속성)—본문: 패널이 접는 것
list—제목 뒤 헤더에 놓이는 아이템
string""헤더 글자(비어 있으면 숨김)
boolfalse열림. 설정하면 조용히 열리거나 닫힘; 사용자와 메서드는 바꾸면서 changed 발생
boolfalse셰브론을 오른쪽 끝 대신 제목 앞 왼쪽에
boolfalse헤더 회색·멈춤; toggle() / open() 무시, close() 허용
boolfalse이 패널만 테두리와 배경 없음
boolfalseeffectiveFullheight(읽기 전용)는 이것 또는 스택의 fullheight
bool (읽기 전용)—패널 또는 스택의 disabled · ghost · 스택의 borderless
bool (읽기 전용)—패널 또는 스택의 disabled · ghost · 스택의 borderless
bool (읽기 전용)—패널 또는 스택의 disabled · ghost · 스택의 borderless
bool (읽기 전용)—포인터가 헤더 위에 있음
bool (읽기 전용)—헤더에 키보드 포커스
varnull소유하는 스택(스택이 설정)

메서드

메서드설명
모든 패널에 open(); accordion이면 무시. 비활성 패널은 닫힌 채
모든 패널에 close()
index(0부터, 스택의 패널 중)의 패널에 open() / close(); 모르는 인덱스: 아무 일 없음
index(0부터, 스택의 패널 중)의 패널에 open() / close(); 모르는 인덱스: 아무 일 없음
패널을 순서대로 반환
열려 있으면 close(), 아니면 open(); 비활성이면 무시
열고 changed({ active: true }) 발생; 비활성이거나 이미 열려 있으면 무시; 아코디언이면 나머지 닫힘
닫고 changed({ active: false }) 발생; 이미 닫혀 있으면 무시; 비활성이어도 허용

시그널

시그널인자시점
detail: { active: bool }사용자 조작, 패널의 메서드, 스택의 메서드, 아코디언 규칙으로 패널이 열리거나 닫힘. 바인딩으로 active를 설정할 때와 아무것도 바꾸지 않는 호출에서는 아님

시그널

항목동작 / 조건
SyCollapse 자체에는 시그널이 없습니다.

동작

항목동작 / 조건
열림. 설정하면 조용히 열리거나 닫힘; 사용자와 메서드는 바꾸면서 changed 발생
사용자 조작, 패널의 메서드, 스택의 메서드, 아코디언 규칙으로 패널이 열리거나 닫힘. 바인딩으로 active를 설정할 때와 아무것도 바꾸지 않는 호출에서는 아님
한 번에 하나만 열림: 하나를 열면 나머지가 닫힘; openAll() 무시
열고 changed({ active: true }) 발생; 비활성이거나 이미 열려 있으면 무시; 아코디언이면 나머지 닫힘
스택에 accordion: true면 (사용자 조작이나 open() / openPanel()로) 패널 하나를 열 때 다른 모든 패널이 닫히고, 그 각각이 changed({ active: false })를 발생시킵니다.
모든 패널에 open(); accordion이면 무시. 비활성 패널은 닫힌 채
셰브론을 오른쪽 끝 대신 제목 앞 왼쪽에
헤더 글자(비어 있으면 숨김)
제목 뒤 헤더에 놓이는 아이템
글자가 줄바꿈되도록 내용에 폭(width: parent.width)을 주십시오.
패널에 테두리 없음(배경은 유지)
모든 패널에 테두리와 배경 없음
모든 헤더 멈춤
열려 있으면 close(), 아니면 open(); 비활성이면 무시
닫고 changed({ active: false }) 발생; 이미 닫혀 있으면 무시; 비활성이어도 허용
모든 패널에 close()
close(), closeAll(), closePanel()은 비활성 패널도 닫습니다.
Tab이 사용 가능한 헤더에 도달하고, Space / Enter가 포커스된 것을 토글합니다.
모든 패널에 적용(각 패널의 effectiveFullheight = 자기 것 또는 스택의 것)
스택의 fullheight는 모든 패널에 닿습니다(패널의 effectiveFullheight는 자기 fullheight 또는 스택의 것): 그러면 열린 본문을 자식의 오프셋 + 높이 대신 자식들의 경계 높이만으로(최소 18 px) 재며, 눈에 띄는 차이는 거의 없습니다.
열린 본문을 자식들의 경계 높이만으로 잼(최소 18 px). effectiveFullheight(읽기 전용)는 이것 또는 스택의 fullheight
패널을 순서대로 반환

키보드

항목동작 / 조건
SyTabGroup은 쌓는 대신 뷰를 전환하고, SyCard는 항상 열려 있는 구역을 감쌉니다.