QML
← 전체 컴포넌트

Checkbox

옵션을 선택하거나 해제하는 체크박스입니다. 여러 항목을 각각 독립적으로 선택할 때 사용합니다.

import Syidax.Core.Checkbox

지원 QML 타입

타입정의 / 역할
독립적인 선택·해제와 일부 선택 상태를 표현하는 체크박스 필드입니다.

예제로 보기

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

01 기본 구성

SyCheckbox는 16 px 상자와 그 옆의 라벨(text)로, 사용자가 체크하고 해제합니다.

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

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

    property QtObject settings: QtObject {
        id: storyArgs
        property string text: "약관에 동의합니다"
        property bool checked: false
        property bool indeterminate: false
        property bool disabled: false
        property bool readonly: false
        property bool required: false
        property string message: ""
    }

    

    SyCheckbox {
        text: storyArgs.text
        checked: storyArgs.checked
        indeterminate: storyArgs.indeterminate
        disabled: storyArgs.disabled
        readonly: storyArgs.readonly
        required: storyArgs.required
        message: storyArgs.message
        onCheckedChanged: if (storyArgs.checked !== checked) storyArgs.checked = checked
        onIndeterminateChanged: if (storyArgs.indeterminate !== indeterminate) storyArgs.indeterminate = indeterminate
    }

}

02 disabled · readonly

disabled: true는 상자와 라벨을 회색으로 만들고 반응하지 않게 합니다.

Qt 실행 화면 · 이미지
disabled · readonly · 기본
기본 실행 화면
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: 8
        SyCheckbox { id: featureTarget0; visible: true; text: "비활성"; disabled: true }
        SyCheckbox { id: featureTarget1; visible: true; text: "비활성"; disabled: true; checked: true }
        SyCheckbox { id: featureTarget2; visible: true; text: "읽기 전용"; readonly: true }
        SyCheckbox { id: featureTarget3; visible: true; text: "읽기 전용"; readonly: true; checked: true }
    }
}

03 indeterminate

indeterminate: true는 체크 표시 대신 대시를 그립니다 — 일부만 체크된 행들 위의 전체 선택 상자처럼, 그룹을 대표하는 상자의 "일부만" 상태입니다.

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

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

    Column {
        spacing: 8
        SyCheckbox {
            id: all
            text: "전체 선택"
            checked: a.checked && b.checked && c.checked
            indeterminate: !checked && (a.checked || b.checked || c.checked)
            onCheckedChanged: { a.checked = checked; b.checked = checked; c.checked = checked }
        }
        Column {
            spacing: 8
            leftPadding: 20
            SyCheckbox { id: a; text: "디자인"; checked: true }
            SyCheckbox { id: b; text: "개발" }
            SyCheckbox { id: c; text: "품질" }
        }
    }
}

04 changed · focused · blured

상자에는 시그널이 셋 있습니다.

Qt 실행 화면 · 이미지
changed · focused · blured · 기본
기본 실행 화면
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
    // Focused Gallery routes: keep only the selected API and its prerequisites.
    id: featureStory

    

    Column {
        spacing: 12
        SyCheckbox {
            text: "뉴스레터 구독"
            onChanged: (detail) => { if (true) { output.log(("changed: checked %1 · indeterminate %2").arg(detail.checked).arg(detail.indeterminate)) } }
            onFocused: { if (true) { output.log("focused") } }
            onBlured: { if (true) { output.log("blured") } }
        }
        EventLog { id: output }
    }
}

05 toggle · setFocus · checkValidity · …

상자의 함수들입니다.

Qt 실행 화면 · 이미지
toggle · setFocus · checkValidity · … · 기본
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
    // Focused Gallery routes: keep only the selected API and its prerequisites.
    id: featureStory

    Column {
        spacing: 12
        SyCheckbox { id: terms; text: "약관에 동의합니다"; required: true }
        Flow {
            width: 560
            spacing: 8
            SyButton { id: exampleControl1;  visible: true; text: "terms.toggle()"; variant: "secondary"; size: "small"; onClicked: terms.toggle() }
            SyButton { id: exampleControl2;  visible: true; text: "terms.setFocus()"; variant: "secondary"; size: "small"; onClicked: terms.setFocus() }
            SyButton { id: exampleControl3;  visible: true; text: "terms.checkValidity()"; variant: "secondary"; size: "small"; onClicked: output.log("checkValidity() → " + terms.checkValidity()) }
            SyButton { visible: true; text: "terms.reportValidity()"; variant: "secondary"; size: "small"; onClicked: output.log("reportValidity() → " + terms.reportValidity()) }
            SyButton { visible: true; text: "terms.getValidStatus()"; variant: "secondary"; size: "small"; onClicked: output.log("getValidStatus() → " + JSON.stringify(terms.getValidStatus())) }
            SyButton { visible: true; text: "terms.setCustomError()"; variant: "secondary"; size: "small"; onClicked: terms.setCustomError() }
            SyButton { visible: true; text: "terms.clearCustomError()"; variant: "secondary"; size: "small"; onClicked: terms.clearCustomError() }
        }
        EventLog { id: output }
    }
}

06 일부 항목 선택

indeterminate · checked 설정을 적용한 일부 항목 선택 예제입니다.

Qt 실행 화면 · 이미지
일부 항목 선택 · 실행 결과
기본 실행 화면
QML 코드
import QtQuick
import Syidax.Core

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

    property QtObject settings: QtObject {
        id: storyArgs
        property string text: "약관에 동의합니다"
        property bool checked: false
        property bool indeterminate: true
        property bool disabled: false
        property bool readonly: false
        property bool required: false
        property string message: ""
    }

    

    SyCheckbox {
        text: storyArgs.text
        checked: storyArgs.checked
        indeterminate: storyArgs.indeterminate
        disabled: storyArgs.disabled
        readonly: storyArgs.readonly
        required: storyArgs.required
        message: storyArgs.message
        onCheckedChanged: if (storyArgs.checked !== checked) storyArgs.checked = checked
        onIndeterminateChanged: if (storyArgs.indeterminate !== indeterminate) storyArgs.indeterminate = indeterminate
    }

}

07 필수 입력과 초기화

검증 전·오류 표시·초기화 결과를 비교합니다.

Qt 실행 화면 · 이미지
필수 입력과 초기화 · 입력 전
QML 코드
import QtQuick
import Syidax.Core

Column {
    width: 440; spacing: 12
    SyCheckbox {
        id: field; width: parent.width; name: "selection"; required: true
        text: "필수 입력"
        
        error: "계속하려면 이 항목을 입력하세요."
    }
    Row {
        spacing: 8
        SyButton { id: check; text: "검증"; onClicked: field.reportValidity() }
        SyButton { id: reset; text: "초기화"; onClicked: field.reset() }
    }
    Text { text: "상태: " + (field.invalid ? "오류" : "입력 준비"); color: Theme.semantic.textDefault }
}

08 사용자 지정 오류

업무 규칙에 맞는 오류를 표시하고 초기화합니다.

Qt 실행 화면 · 이미지
사용자 지정 오류 · 입력 전
QML 코드
import QtQuick
import Syidax.Core

Column {
    width: 440; spacing: 12
    SyCheckbox {
        id: field; width: parent.width; name: "selection"; required: true
        text: "필수 입력"
        checked: true
        error: "현재 사용할 수 없는 선택입니다. 다른 값을 선택하세요."
    }
    Row {
        spacing: 8
        SyButton { id: check; text: "오류 표시"; onClicked: field.setCustomError() }
        SyButton { id: reset; text: "초기화"; onClicked: field.reset() }
    }
    Text { text: "상태: " + (field.invalid ? "오류" : "입력 준비"); color: Theme.semantic.textDefault }
}

API 69

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

속성

항목동작 / 조건
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.
공통 필드 속성(name, label, required, disabled, message, error, touched, submitted, customError, validStatus, valid, invalid, showTitle, ready)은 Form 페이지에 설명되어 있습니다.

속성

속성타입기본값설명
boolfalse상태. 클릭·Space·toggle()이 뒤집고, 바뀔 때마다 changed 발생.
boolfalse상태 위에 대시("일부만" 모양)를 그립니다. 다음 클릭이 상자를 체크하고 이를 지웁니다. 단독으로는 changed 없음.
string""상자 옆 라벨. 클릭해도 토글됩니다.
Item…—기본 속성. 안에 선언한 아이템은 라벨 텍스트 뒤에 4 px 간격, 가운데 정렬로 놓입니다.
string"on"체크된 동안 소속 SyForm이 name으로 제출하는 값.
var(읽기 전용)—체크되면 value, 아니면 null — SyForm.values()가 저장하는 것.
string""소속 SyForm의 values()에서의 키.
boolfalse체크 안 됨 → valueMissing.
boolfalse반응 없고 회색. Tab 정지점 아님. 항상 유효. 제출되지 않음.
boolfalse포커스는 되지만 바꿀 수 없음. 항상 유효. 제출됨.
string""호버 텍스트: 포인터가 체크박스 위에 머물면 SyTooltip으로 보입니다.
string""행 아래 도움말 줄
string""필수 검사의 사용자 정의 오류 문구.
string""상속된 제목 줄(행 위). 보통 비워 둡니다.
string"medium"상속됨. 체크박스에는 효과가 없습니다.
bool(읽기 전용)—상자가 활성 포커스를 가짐
bool(읽기 전용)—포인터가 행 위에 있음(disabled에서는 false).
string(읽기 전용)—unchecked · checked · indeterminate.
string(읽기 전용)—enabled · hover · focus · readonly · disabled.

메서드

메서드설명
클릭: indeterminate → checked, 아니면 checked 뒤집기. disabled·readonly 동안 무시.
상자에 키보드 포커스를 주기 / 거두기(focused / blured 발생, 블러는 touched 설정).
상자에 키보드 포커스를 주기 / 거두기(focused / blured 발생, 블러는 touched 설정).
필수 상자가 체크되지 않은 경우(또는 사용자 정의 오류)가 아니면 true. 조용히.
같은 결과, 그리고 이제부터 오류 줄이 보임.
"" · valueMissing · custom.
"" · valueMissing · custom.
custom 상태 강제 / 해제. 오류가 즉시 보임.
custom 상태 강제 / 해제. 오류가 즉시 보임.
checked(생성 시 값 initialChecked)와 value를 복원하고 touched·보고·custom 플래그를 지움.

시그널

시그널인자발생 시점
detail: { value: bool, isValid: bool, checked: bool, indeterminate: bool } — value는 새 checked로딩 뒤 checked가 바뀜 — 사용자든 코드든. 초기값과 indeterminate만 바뀔 때는 발생하지 않음.
true상자가 활성 포커스를 얻음.
false상자가 포커스를 잃음. 먼저 touched가 설정됨.

동작

항목동작 / 조건
상태. 클릭·Space·toggle()이 뒤집고, 바뀔 때마다 changed 발생.
클릭: indeterminate → checked, 아니면 checked 뒤집기. disabled·readonly 동안 무시.
로딩 뒤 checked가 바뀜 — 사용자든 코드든. 초기값과 indeterminate만 바뀔 때는 발생하지 않음.
상태 위에 대시("일부만" 모양)를 그립니다. 다음 클릭이 상자를 체크하고 이를 지웁니다. 단독으로는 changed 없음.
체크되면 value, 아니면 null — SyForm.values()가 저장하는 것.
체크된 동안 소속 SyForm이 name으로 제출하는 값.
소속 SyForm의 values()에서의 키.
체크 안 됨 → valueMissing.
required는 체크 안 된 상자를 valueMissing으로 만들고, 행 아래 오류 줄("This field is required" 또는 error)은 상자를 떠난(touched) 뒤나 보고된(submitted) 뒤 나타납니다.
required는 체크 안 된 상자를 valueMissing으로 만들고, 행 아래 오류 줄("This field is required" 또는 error)은 상자를 떠난(touched) 뒤나 보고된(submitted) 뒤 나타납니다.
required는 체크 안 된 상자를 valueMissing으로 만들고, 행 아래 오류 줄("This field is required" 또는 error)은 상자를 떠난(touched) 뒤나 보고된(submitted) 뒤 나타납니다.
반응 없고 회색. Tab 정지점 아님. 항상 유효. 제출되지 않음.
포커스는 되지만 바꿀 수 없음. 항상 유효. 제출됨.
disabled가 아니면 Tab이 상자에 멈춥니다(읽기 전용 상자도 Tab 정지점). Space가 토글하고 Enter는 아무 일도 하지 않습니다. 포커스 링은 상자가 포커스를 갖고 disabled가 아닌 동안 상자 둘레에 그려집니다. 상자가 상호작용 가능하면 손 모양 커서, disabled·readonly이면 화살표입니다.
disabled는 상자와 라벨을 회색으로 만들고 모든 상호작용과 Tab 정지를 막으며 SyForm.values()가 건너뜁니다.
색조: disabled > readonly > focus > hover > enabled, 각각 현재 모드에서.
색조: disabled > readonly > focus > hover > enabled, 각각 현재 모드에서.
상자가 활성 포커스를 얻음.
상자가 포커스를 잃음. 먼저 touched가 설정됨.
상속됨. 체크박스에는 효과가 없습니다.
상속된 제목 줄(행 위). 보통 비워 둡니다.
상자 옆 라벨. 클릭해도 토글됩니다.
색은 모드와 상태별 Theme.checkbox에서 오고 Theme.scheme을 따릅니다.