QML
← All components

Popconfirm

Ask for confirmation beside the action that needs it, such as deleting an item.

import Syidax.Core.Popconfirm

Supported QML types

TypeDefinition / role
Anchored confirmation popup with confirm and cancel actions.

Learn by example

Previews are images of native Qt runs. Use the buttons below each image to view a result.

01 Basic composition

SyPopconfirm is a popover that asks before acting: declare it inside the item that needs confirming

Qt capture · image
Basic composition · Opened
QML code
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") : "Interact with the controls to see event results."
            wrapMode: Text.Wrap; color: Theme.semantic.textDefault
            font.family: Theme.monoFontFamily; font.pixelSize: 12
        }
    }

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

    property QtObject settings: QtObject {
        id: storyArgs
        property string position: "top"
        property string trigger: "click"
        property bool arrow: true
        property string confirmText: "OK"
        property string cancelText: "Cancel"
        property bool sticky: false
        property string animation: "none"
    }

    

    Item {
        width: 320
        height: 140
        Column {
            anchors.centerIn: parent
            spacing: 12
            SyButton {
                text: "Delete"
                SyPopconfirm { id: exampleControl1; 
                    position: storyArgs.position
                    trigger: storyArgs.trigger
                    arrow: storyArgs.arrow
                    confirmText: storyArgs.confirmText
                    cancelText: storyArgs.cancelText
                    sticky: storyArgs.sticky
                    animation: storyArgs.animation
                    onSelected: (choice) => output.log(choice)
                    Text { text: "Delete this row?"; font.family: Theme.fontFamily; font.pixelSize: 13; color: Theme.popconfirm.textEnabled }
                }
            }
            EventLog { id: output; width: 280 }
        }
    }

}

02 position · arrow

Compare the configuration and result of position · arrow.

Qt capture · image
position · arrow · Default
Default execution
QML code
import QtQuick
import Syidax.Core

pragma ComponentBehavior: Bound

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

    id: story
    readonly property var positions: ["top", "bottom"]

    Item {
        width: 420
        height: 300
        Row {
            anchors.centerIn: parent
            spacing: 120
            Repeater {
                model: story.positions
                delegate: SyButton {
                    id: cell
                    required property string modelData
                    text: cell.modelData
                    width: 100
                    SyPopconfirm { id: featureTarget0;
                        position: cell.modelData; arrow: true; trigger: "none"
                        Component.onCompleted: { Qt.callLater(setOpen);  }
                        Text { text: "Delete this row?"; font.family: Theme.fontFamily; font.pixelSize: 13; color: Theme.popconfirm.textEnabled }
                    }
                }
            }
        }
    }
}

03 confirmText · cancelText

confirmText and cancelText are the labels of the two buttons — "OK" and "Cancel" by default; set them to the verbs of the decision ("Yes, publish" / "Not yet", "Delete" / "Keep").

Qt capture · image
confirmText · cancelText · Opened
QML code
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

    SyButton {
        text: "Publish"
        SyPopconfirm { id: featureTarget0;
            confirmText: "Publish now"; cancelText: "Not yet"; arrow: true
            Column {
                spacing: 4
                Text { text: "Publish the page?"; font.weight: Font.Medium; font.family: Theme.fontFamily; font.pixelSize: 14; color: Theme.popconfirm.textEnabled }
                Text { text: "Everyone with the link will see it."; color: Theme.semantic.textSubtle; font.family: Theme.fontFamily; font.pixelSize: 12 }
            }
        }
    }
}

04 selected · visibleChanged

selected(choice) fires when one of the two buttons is pressed — or when okClick() / cancelClick() is called — with choice as the string "ok" or "cancel"; the popconfirm closes right after.

Qt capture · image
selected · visibleChanged · Opened
QML code
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") : "Interact with the controls to see event results."
            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
        SyButton {
            text: "Delete"
            SyPopconfirm {
                id: confirm
                arrow: true
                onSelected: (choice) => { if (true) { output.log(("selected: %1").arg(choice)) } }
                onVisibleChanged: { if (true) { output.log(("visible: %1").arg(confirm.visible)) } }
                Text { text: "Delete this row?"; font.family: Theme.fontFamily; font.pixelSize: 13; color: Theme.popconfirm.textEnabled }
            }
        }
        EventLog { id: output }
    }
}

05 setOpen · setClose · okClick · cancelClick

setOpen() opens the popconfirm and setClose() closes it from code, whatever the trigger; setOpen() still refuses a disabled anchor and setClose() closes even a sticky one, and neither emits selected.

Qt capture · image
setOpen · setClose · okClick · cancelClick · Opened
QML code
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") : "Interact with the controls to see event results."
            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: 24
        Item {
            width: 560; height: 220
            SyButton {
                x: 24; y: 24
 text: "Delete"; SyPopconfirm { id: confirm; trigger: "none"; arrow: true; onSelected: (choice) => output.log(choice); Text { text: "Delete this row?"; font.family: Theme.fontFamily; font.pixelSize: 13; color: Theme.popconfirm.textEnabled } } }
        }
        Flow {
            objectName: "exampleCommands"

            width: 560
            spacing: 8
            SyButton { id: exampleControl1;  visible: true; text: "confirm.setOpen()"; variant: "secondary"; size: "small"; onClicked: confirm.setOpen() }
            SyButton { id: exampleControl2;  visible: true; text: "confirm.setClose()"; variant: "secondary"; size: "small"; onClicked: confirm.setClose() }
            SyButton { id: exampleControl3;  visible: true; text: "confirm.okClick()"; variant: "secondary"; size: "small"; onClicked: confirm.okClick() }
            SyButton { id: exampleControl4;  visible: true; text: "confirm.cancelClick()"; variant: "secondary"; size: "small"; onClicked: confirm.cancelClick() }
        }
        EventLog { id: output }
    }
}

06 Confirmation without arrow

Confirmation without arrow, configured with arrow.

Qt capture · image
Confirmation without arrow · Opened
QML code
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") : "Interact with the controls to see event results."
            wrapMode: Text.Wrap; color: Theme.semantic.textDefault
            font.family: Theme.monoFontFamily; font.pixelSize: 12
        }
    }

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

    property QtObject settings: QtObject {
        id: storyArgs
        property string position: "top"
        property string trigger: "click"
        property bool arrow: false
        property string confirmText: "OK"
        property string cancelText: "Cancel"
        property bool sticky: false
        property string animation: "none"
    }

    

    Item {
        width: 320
        height: 140
        Column {
            anchors.centerIn: parent
            spacing: 12
            SyButton {
                text: "Delete"
                SyPopconfirm { id: exampleControl1; 
                    position: storyArgs.position
                    trigger: storyArgs.trigger
                    arrow: storyArgs.arrow
                    confirmText: storyArgs.confirmText
                    cancelText: storyArgs.cancelText
                    sticky: storyArgs.sticky
                    animation: storyArgs.animation
                    onSelected: (choice) => output.log(choice)
                    Text { text: "Delete this row?"; font.family: Theme.fontFamily; font.pixelSize: 13; color: Theme.popconfirm.textEnabled }
                }
            }
            EventLog { id: output; width: 280 }
        }
    }

}

API 62

Hover or select an item for its QML example and copy button.

Properties

PropertyTypeDefaultDescription
list (default property)—The question: the items declared inside, shown above the buttons.
string"OK"Label of the primary button (emits selected("ok")).
string"Cancel"Label of the secondary button (emits selected("cancel")).
string"top""top" · "topLeft" · "topRight" · "bottom" · "bottomLeft" · "bottomRight" · "left" · "leftTop" · "leftBottom" · "right" · "rightTop" · "rightBottom".
string"click""click" (a tap on the anchor toggles) · "none" (code only).
boolfalseShow the pointer towards the anchor.
boolfalseNo Escape / outside-press close; the buttons and setClose() still close it.
int0Milliseconds before opening / closing.
int0Milliseconds before opening / closing.
string"none""none" · "fade"; speed "x-fast" · "fast" · "medium" · "slow" · "x-slow".
string"fast""none" · "fade"; speed "x-fast" · "fast" · "medium" · "slow" · "x-slow".
Itemthe item it is declared inThe item it follows (resolved to the nearest ancestor with hovered within three levels).
bool (read-only)—The popconfirm is visible.
string (read-only)—The side after flipping, with -start / -end.
colorpopconfirm tokensThe surface look.
colorsubtle borderThe surface look.
real2The surface look.
booltrueThe surface look.
real12Space between the content and the edge.
real10 / 4Base popup geometry.
booltrueBase popup geometry.
boolfalseBase popup geometry.
read-only—The resolved speed, the current side, whether the anchor accepts opening, the anchor's rectangle in overlay coordinates.
read-only—The resolved speed, the current side, whether the anchor accepts opening, the anchor's rectangle in overlay coordinates.
read-only—The resolved speed, the current side, whether the anchor accepts opening, the anchor's rectangle in overlay coordinates.
read-only—The resolved speed, the current side, whether the anchor accepts opening, the anchor's rectangle in overlay coordinates.

Methods

MethodDescription
Emits selected("ok") and closes — exactly what the OK button does; works even while closed.
Emits selected("cancel") and closes — exactly what the Cancel button does.
Cancels pending delays and opens, whatever the trigger — unless the anchor is disabled / readonly / not enabled.
Cancels pending delays and closes without selected, even when sticky.
The base popup's immediate open / close and the trigger-style toggle.
The base popup's immediate open / close and the trigger-style toggle.
The base popup's immediate open / close and the trigger-style toggle.
Re-computes the placement; automatic on anchor, size and window changes.

Signals

SignalArgumentsWhen
choice: string — "ok" or "cancel"A button was pressed, or okClick() / cancelClick() was called; the popup closes right after. Not emitted for Escape, an outside press, setClose() or the anchor toggle.
— (read visible / isOpen)The popup opened or closed, by any path.
—Emitted just before the popup is shown.
—Emitted after the popup finishes its enter transition.
—Emitted just before the popup is hidden.
—Emitted after the popup finishes its exit transition.

Behavior

ItemBehavior / conditions
the item the popconfirm is declared in; inside a control's content it walks up at most three parents to the nearest item with a boolean hovered, so the control itself is the anchor. It is parented to the anchor and drawn in the window overlay, following the anchor.
"click" (a tap on the anchor toggles) · "none" (code only).
Cancels pending delays and opens, whatever the trigger — unless the anchor is disabled / readonly / not enabled.
Cancels pending delays and closes without selected, even when sticky.
A disabled or readonly anchor never opens it; opendelay applies to the click, and closing by any route — Escape, an outside press, close() — cancels a pending delayed open.
A disabled or readonly anchor never opens it; opendelay applies to the click, and closing by any route — Escape, an outside press, close() — cancels a pending delayed open.
A button was pressed, or okClick() / cancelClick() was called; the popup closes right after. Not emitted for Escape, an outside press, setClose() or the anchor toggle.
Emits selected("ok") and closes — exactly what the OK button does; works even while closed.
Emits selected("cancel") and closes — exactly what the Cancel button does.
The popup opened or closed, by any path.
Watch visibleChanged / closed() to notice it.
No Escape / outside-press close; the buttons and setClose() still close it.
the content (the default property; give your items sizes or a Column) over a right-aligned row of two small buttons: cancelText (default style) then confirmText (primary), 4 px apart, 8 px under the content; the content is at least as wide as the buttons. 12 px padding, 2 px radius, a subtle 1 px border and a soft shadow. The surface sets no text color — use Theme.popconfirm.textEnabled.
"top" · "topLeft" · "topRight" · "bottom" · "bottomLeft" · "bottomRight" · "left" · "leftTop" · "leftBottom" · "right" · "rightTop" · "rightBottom".
The side after flipping, with -start / -end.
Show the pointer towards the anchor.
Animation — animation: "fade" (any name other than "none") fades over animationMs (x-fast 100 · fast 150 · medium 250 · slow 350 · x-slow 500); none under Theme.reducedMotion.
Animation — animation: "fade" (any name other than "none") fades over animationMs (x-fast 100 · fast 150 · medium 250 · slow 350 · x-slow 500); none under Theme.reducedMotion.
The popconfirm is visible.
State — isOpen is the popup's visible.

Keyboard

ItemBehavior / conditions
SyModal for bigger decisions, SyPopover for information without a decision, SyTooltip for a hint; SyButton as the usual anchor and for the two buttons inside.
closable (default true) controls outside/Escape dismissal independently of sticky. OK/Cancel and setClose() remain explicit close actions even with closable=false.