QML
← 전체 컴포넌트

Toast

저장 완료나 요청 실패처럼 작업 결과를 잠깐 알리는 메시지입니다.

import Syidax.Core.Toast

지원 QML 타입

타입정의 / 역할
종류별 토스트 알림을 생성하고 닫는 비시각적 관리 타입입니다.
창 모서리에 표시되며 직접 닫거나 시간이 지나면 닫히는 개별 토스트 알림입니다.
싱글턴열린 토스트의 배치를 관리하는 공용 싱글턴이며 SyToastItem이 자동으로 등록합니다.

예제로 보기

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

01 기본 구성

토스트는 창 모서리에 붙는 잠깐 동안의 알림입니다.

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 position: "bottomRight"
        property bool closable: true
        property int duration: 3000
        property bool latestTop: false
        property string animation: "fade"
    }

    readonly property string optionText: "{ header: " + JSON.stringify("저장됨") + ", body: " + JSON.stringify("변경 사항이 반영됐습니다.") + (storyArgs.closable ? ", closable: true" : "") + (storyArgs.position !== "bottomRight" ? ", position: " + JSON.stringify(storyArgs.position) : "") + " }"

    Column {
        spacing: 12
        SyToast {
            id: toaster
            duration: storyArgs.duration
            latestTop: storyArgs.latestTop
            animation: storyArgs.animation
        }
        Row {
            spacing: 8
            SyButton { id: exampleControl1;  text: "저장됨"; onClicked: toaster.createSuccessToast({ header: "저장됨", body: "변경 사항이 반영됐습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { id: exampleControl2;  text: "실패"; onClicked: toaster.createErrorToast({ header: "실패", body: "서버가 응답하지 않았습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { id: exampleControl3;  text: "업데이트"; onClicked: toaster.createInfoToast({ header: "업데이트", body: "새 버전이 준비됐습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { text: "주의"; onClicked: toaster.createWarningToast({ header: "주의", body: "세션이 5분 뒤 끝납니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { text: "메모"; onClicked: toaster.createNeutralToast({ header: "메모", body: "더 할 일은 없습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
        }
        Text {
            text: "toaster.toasts.length === " + toaster.toasts.length
            font.family: Theme.monoFontFamily
            font.pixelSize: 12
            color: Theme.semantic.textSubtle
        }
    }

}

02 SyToastItem · variant · closable · footer · icon

SyToastItem은 호스트가 만드는 대신 손으로 선언하는 카드 자체입니다: open: true는 만들어지자마자 보여 주고 open: false(또는 close())는 내립니다.

Qt 실행 화면 · 이미지
SyToastItem · variant · closable · footer · icon · 기본
기본 실행 화면
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: 12
        SyToastItem { id: featureTarget0; visible: true; open: true; variant: "success"; title: "저장됨"; message: "변경 사항이 반영됐습니다."; closable: true }
        SyToastItem { id: featureTarget1; visible: true; open: true; variant: "error"; title: "실패"; message: "서버가 응답하지 않았습니다."; closable: true }
        SyToastItem { id: featureTarget2; visible: true; open: true; variant: "info"; title: "업데이트"; message: "새 버전이 준비됐습니다." }
        SyToastItem { id: featureTarget3; visible: true; open: true; variant: "warning"; title: "주의"; message: "세션이 5분 뒤 끝납니다."; footer: Text { text: "방금"; font.family: Theme.fontFamily; font.pixelSize: 12; color: Theme.toast.timestampTextEnabled } }
        SyToastItem { id: featureTarget4; visible: true; open: true; variant: "neutral"; title: "메모"; message: "더 할 일은 없습니다."; icon: SyIcon { source: Icons.toastInfo; size: "xxlarge"; anchors.centerIn: parent } }
        Text {
            text: "처음부터 열려 있음: 창의 오른쪽 아래 모서리에 쌓입니다."
            font.family: Theme.fontFamily
            font.pixelSize: 13
            color: Theme.semantic.textSubtle
        }
    }
}

03 created · closed

두 타입에 시그널 둘.

Qt 실행 화면 · 이미지
created · closed · 업데이트 실행 결과
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
        SyToast {
            id: toaster
            duration: 2000
            onCreated: (item) => { if (true) { {
                output.log(("created: %1").arg(item.title))
                item.closed.connect(() => output.log(("closed: %1").arg(item.title)))
            } } }
        }
        SyButton { id: exampleControl1;  text: "업데이트"; onClicked: toaster.createInfoToast({ header: "업데이트", body: "새 버전이 준비됐습니다.", closable: true }) }
        EventLog { id: output }
    }
}

04 createToast · closeToast · closeAll

호스트의 메서드입니다.

Qt 실행 화면 · 이미지
createToast · closeToast · closeAll · toaster.createToast("warning", …) 실행 결과
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
        SyToast { id: toaster; duration: 0 }
        Flow {
            width: 520
            spacing: 8
            SyButton { id: exampleControl1;  visible: true; text: "toaster.createToast(\"warning\", …)"; variant: "secondary"; size: "small"; onClicked: toaster.createToast("warning", { header: "주의", body: "세션이 5분 뒤 끝납니다.", closable: true }) }
            SyButton { id: exampleControl2;  visible: true; text: "toaster.closeToast(…)"; variant: "secondary"; size: "small"; onClicked: toaster.closeToast(toaster.toasts[toaster.toasts.length - 1]) }
            SyButton { id: exampleControl3;  visible: true; text: "toaster.closeAll()"; variant: "secondary"; size: "small"; onClicked: toaster.closeAll() }
        }
        Text {
            text: "toaster.toasts.length === " + toaster.toasts.length
            font.family: Theme.monoFontFamily
            font.pixelSize: 12
            color: Theme.semantic.textSubtle
        }
    }
}

05 지속 알림

duration · closable 설정을 적용한 지속 알림 예제입니다.

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 position: "bottomRight"
        property bool closable: true
        property int duration: 0
        property bool latestTop: false
        property string animation: "fade"
    }

    readonly property string optionText: "{ header: " + JSON.stringify("저장됨") + ", body: " + JSON.stringify("변경 사항이 반영됐습니다.") + (storyArgs.closable ? ", closable: true" : "") + (storyArgs.position !== "bottomRight" ? ", position: " + JSON.stringify(storyArgs.position) : "") + " }"

    Column {
        spacing: 12
        SyToast {
            id: toaster
            duration: storyArgs.duration
            latestTop: storyArgs.latestTop
            animation: storyArgs.animation
        }
        Row {
            spacing: 8
            SyButton { id: exampleControl1;  text: "저장됨"; onClicked: toaster.createSuccessToast({ header: "저장됨", body: "변경 사항이 반영됐습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { text: "실패"; onClicked: toaster.createErrorToast({ header: "실패", body: "서버가 응답하지 않았습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { text: "업데이트"; onClicked: toaster.createInfoToast({ header: "업데이트", body: "새 버전이 준비됐습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { text: "주의"; onClicked: toaster.createWarningToast({ header: "주의", body: "세션이 5분 뒤 끝납니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { text: "메모"; onClicked: toaster.createNeutralToast({ header: "메모", body: "더 할 일은 없습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
        }
        Text {
            text: "toaster.toasts.length === " + toaster.toasts.length
            font.family: Theme.monoFontFamily
            font.pixelSize: 12
            color: Theme.semantic.textSubtle
        }
    }

}

06 최신 알림부터 표시

position · latestTop 설정을 적용한 최신 알림부터 표시 예제입니다.

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 position: "topRight"
        property bool closable: true
        property int duration: 3000
        property bool latestTop: true
        property string animation: "fade"
    }

    readonly property string optionText: "{ header: " + JSON.stringify("저장됨") + ", body: " + JSON.stringify("변경 사항이 반영됐습니다.") + (storyArgs.closable ? ", closable: true" : "") + (storyArgs.position !== "bottomRight" ? ", position: " + JSON.stringify(storyArgs.position) : "") + " }"

    Column {
        spacing: 12
        SyToast {
            id: toaster
            duration: storyArgs.duration
            latestTop: storyArgs.latestTop
            animation: storyArgs.animation
        }
        Row {
            spacing: 8
            SyButton { id: exampleControl1;  text: "저장됨"; onClicked: toaster.createSuccessToast({ header: "저장됨", body: "변경 사항이 반영됐습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { text: "실패"; onClicked: toaster.createErrorToast({ header: "실패", body: "서버가 응답하지 않았습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { text: "업데이트"; onClicked: toaster.createInfoToast({ header: "업데이트", body: "새 버전이 준비됐습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { text: "주의"; onClicked: toaster.createWarningToast({ header: "주의", body: "세션이 5분 뒤 끝납니다.", closable: storyArgs.closable, position: storyArgs.position }) }
            SyButton { text: "메모"; onClicked: toaster.createNeutralToast({ header: "메모", body: "더 할 일은 없습니다.", closable: storyArgs.closable, position: storyArgs.position }) }
        }
        Text {
            text: "toaster.toasts.length === " + toaster.toasts.length
            font.family: Theme.monoFontFamily
            font.pixelSize: 12
            color: Theme.semantic.textSubtle
        }
    }

}

API 71

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

속성 · SyToast(호스트)

속성타입기본값설명
int3000만든 토스트의 기본 duration(ms).
boolfalse만든 토스트가 이 latestTop을 받습니다: 가장 새 것이 모서리에 가장 가깝게.
string"none"만든 토스트의 기본 animation: "none" · "fade" · "slide" / "slide-…".
string"fast"기본 속도: "x-fast" · "fast" · "medium" · "slow" · "x-slow".
var[]아직 열린 만든 아이템, 생성 순서(가장 새 것이 마지막). 손으로 선언한 아이템은 포함되지 않습니다.

속성 · SyToastItem(카드)

속성타입기본값설명
list (기본 속성)—메시지 아래 열로 놓이는 아이템.
list—24 × 24 px 아이콘 상자에 그려지는 아이템. neutral 토스트에 아이콘을 주는 방법입니다.
list—내용 아래(위로 16 px) 행에 놓이는 아이템.
string""16 px 헤더 줄. 비어 있으면 숨김.
string""14 px 본문. 비어 있으면 숨김.
boolfalsetrue는 카드를 보여 주고 false는 내립니다.
string"bottomRight""bottomRight" · "bottomLeft" · "topRight" · "topLeft" — 모서리.
string"neutral""neutral" · "success" · "error" · "info" · "warning" — 색과 아이콘.
boolfalseclose()를 부르는 ×를 더합니다.
int0스스로 닫히기까지의 밀리초. 0 = 유지. 호버 중 멈추고 떠나면 전체 길이로 다시 시작.
boolfalse가장 새 것이 모서리에 가장 가깝게 — 그 모서리의 아이템 하나라도 설정하면 모서리 전체에 적용.
string"none"등장 애니메이션과 속도(동작 참조).
string"fast"등장 애니메이션과 속도(동작 참조).
boolfalse닫힌 뒤 아이템을 파괴. SyToast가 만든 토스트에 설정합니다.
real0가장자리를 따라 모서리에서 떨어진 거리. ToastStack이 기록합니다.
bool (읽기 전용)—카드가 화면에 있음(보여진 때부터 사라짐이 끝날 때까지 true).
real (읽기 전용)—카드의 현재 높이.
bool (읽기 전용)—모서리가 닿는 가장자리.
bool (읽기 전용)—모서리가 닿는 가장자리.
int (읽기 전용)—계산된 애니메이션 길이("none"이나 모션 감소이면 0).
읽기 전용—variant의 테마 색과 아이콘.
읽기 전용—variant의 테마 색과 아이콘.
읽기 전용—variant의 테마 색과 아이콘.
읽기 전용—variant의 테마 색과 아이콘.
읽기 전용—variant의 테마 색과 아이콘.

속성 · ToastStack(싱글턴)

속성타입기본값설명
var[]창의 모든 열린 SyToastItem(모든 호스트와 손으로 선언한 것 포함), 보인 순서.

메서드

메서드설명
SyToastItem을 만들어 보여 주고 반환합니다. variant: "success" · "error" · "info" · "warning" · "neutral". option(모든 필드 선택, 생략 가능): header, body, footer(글), icon(url), position, closable, duration, animation, animationSpeed.
variant를 채운 createToast. 같은 option, 같은 반환.
variant를 채운 createToast. 같은 option, 같은 반환.
variant를 채운 createToast. 같은 option, 같은 반환.
variant를 채운 createToast. 같은 option, 같은 반환.
variant를 채운 createToast. 같은 option, 같은 반환.
그 아이템을 닫습니다(item.close()). null / undefined는 무시. 이 호스트가 만든 것이 아니어도 어떤 SyToastItem에나 동작합니다.
이 호스트가 만든 열린 아이템을 모두 닫습니다.
open을 true / false로 설정합니다.
open을 true / false로 설정합니다.
등록, 해제, 다시 쌓기. 아이템이 스스로 호출하므로 열린 아이템의 latestTop을 바꾼 뒤 layout()을 부를 때만 필요합니다.
등록, 해제, 다시 쌓기. 아이템이 스스로 호출하므로 열린 아이템의 latestTop을 바꾼 뒤 layout()을 부를 때만 필요합니다.
아이템이 스스로 호출하므로 열린 아이템의 latestTop을 바꾼 뒤 layout()을 부를 때만 필요합니다.

시그널

시그널인자발생 시점
item: SyToastItem — 방금 만든 아이템create*Toast 호출이 아이템을 만들어 보여 준 뒤. 손으로 선언한 아이템에는 발생하지 않습니다.
—카드가 사라짐: ×, 시계, close(), closeToast / closeAll, open = false 뒤, 그리고 사라지는 페이드 뒤. 한 번도 보이지 않았으면 발생하지 않습니다. 만든 아이템은 직후 파괴됩니다.

동작

항목동작 / 조건
SyToastItem을 만들어 보여 주고 반환합니다. variant: "success" · "error" · "info" · "warning" · "neutral". option(모든 필드 선택, 생략 가능): header, body, footer(글), icon(url), position, closable, duration, animation, animationSpeed.
16 px 헤더 줄. 비어 있으면 숨김.
14 px 본문. 비어 있으면 숨김.
"bottomRight" · "bottomLeft" · "topRight" · "topLeft" — 모서리.
close()를 부르는 ×를 더합니다.
스스로 닫히기까지의 밀리초. 0 = 유지. 호버 중 멈추고 떠나면 전체 길이로 다시 시작.
토스트 만들기 — createToast(variant, option)은 호스트의 자식으로 SyToastItem을 만듭니다: title = option.header, message = option.body, position = option.position(없으면 "bottomRight" — 호스트에는 position 기본값이 없습니다), closable = option.closable === true, duration / animation / animationSpeed는 option에서, 없으면 호스트에서, latestTop은 항상 호스트에서, 그리고 disposable: true.
토스트 만들기 — createToast(variant, option)은 호스트의 자식으로 SyToastItem을 만듭니다: title = option.header, message = option.body, position = option.position(없으면 "bottomRight" — 호스트에는 position 기본값이 없습니다), closable = option.closable === true, duration / animation / animationSpeed는 option에서, 없으면 호스트에서, latestTop은 항상 호스트에서, 그리고 disposable: true.
가장 새 것이 모서리에 가장 가깝게 — 그 모서리의 아이템 하나라도 설정하면 모서리 전체에 적용.
닫힌 뒤 아이템을 파괴. SyToast가 만든 토스트에 설정합니다.
아직 열린 만든 아이템, 생성 순서(가장 새 것이 마지막). 손으로 선언한 아이템은 포함되지 않습니다.
create*Toast 호출이 아이템을 만들어 보여 준 뒤. 손으로 선언한 아이템에는 발생하지 않습니다.
그 아이템을 닫습니다(item.close()). null / undefined는 무시. 이 호스트가 만든 것이 아니어도 어떤 SyToastItem에나 동작합니다.
이 호스트가 만든 열린 아이템을 모두 닫습니다.
카드가 사라짐: ×, 시계, close(), closeToast / closeAll, open = false 뒤, 그리고 사라지는 페이드 뒤. 한 번도 보이지 않았으면 발생하지 않습니다. 만든 아이템은 직후 파괴됩니다.
true는 카드를 보여 주고 false는 내립니다.
show() / close()가 이것을 설정합니다.
show() / close()가 이것을 설정합니다.
창 오버레이(모든 것 위)의 300 px 너비 패널로, 모서리의 두 가장자리에서 16 px 떨어지고 스택이 가장자리를 따라 밀어 둡니다. 아이템 자체는 선언된 자리에서 보이지 않으므로 포지셔너가 건너뜁니다.
만든 토스트가 이 latestTop을 받습니다: 가장 새 것이 모서리에 가장 가깝게.
만든 토스트의 기본 duration(ms). 0 = 유지.
24 × 24 px 아이콘 상자에 그려지는 아이템. neutral 토스트에 아이콘을 주는 방법입니다.
기본 속도: "x-fast" · "fast" · "medium" · "slow" · "x-slow".
아이콘 상자 · 열(16 px medium 제목, 14 px 메시지, 선언한 내용, 위에 16 px를 둔 푸터 행) · × — 12 px 여백, 부분 사이 8 px. 제목과 메시지는 줄바꿈됩니다.

키보드

항목동작 / 조건
컨트롤 하나에 대한 피드백에는 SyInlineMessage, 지속되는 페이지 전체 공지에는 SyBannerMessage, 답이 필요한 메시지에는 SyModal, 사용자 아이콘에는 SyIcon / Icons.toast*.