QML
← All components

Global Header

Build an application header with branding, navigation, search and common actions.

import Syidax.Core.GlobalHeader

Supported QML types

TypeDefinition / role
Application header combining branding, navigation tabs and actions.

Learn by example

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

01 Basic composition

Compare the configuration and result of Basic composition.

Qt capture · image
Basic composition · Default
Default execution
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 title: "Console"
        property bool search: true
        property bool information: true
        property bool notification: true
    }

    

    Column {
        spacing: 12
        SyGlobalHeader {
            width: 760
            title: storyArgs.title
            search: storyArgs.search
            information: storyArgs.information
            notification: storyArgs.notification
            onSelected: (detail) => output.log(detail.tabkey)
            tabs: [
                SyTab { tabkey: "home"; text: "Home" },
                SyTab { tabkey: "data"; text: "Data" },
                SyTab { tabkey: "reports"; text: "Reports" }
            ]
        }
        EventLog { id: output }
    }

}

02 logo · tabs · actions

Three list properties take items.

Qt capture · image
logo · tabs · actions · Default
Default execution
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

    property QtObject settings: QtObject {
        id: storyArgs
        property int width: 560
    }

    

    SyGlobalHeader { id: featureTarget0;
        width: storyArgs.width
        title: "Console"
        logo: Rectangle { width: 28; height: 28; radius: 6; color: Theme.semantic.backgroundBrandBold; Text { anchors.centerIn: parent; text: "SY"; font.family: Theme.fontFamily; font.pixelSize: 12; font.weight: Font.Bold; color: "white" } }
        tabs: [
            SyTab { tabkey: "home"; text: "Home" },
            SyTab { tabkey: "data"; text: "Data" },
            SyTab { tabkey: "reports"; text: "Reports" },
            SyTab { tabkey: "settings"; text: "Settings" },
            SyTab { tabkey: "admin"; text: "Admin" }
        ]
        actions: SyButton { text: "Sign in"; size: "small" }
    }
}

03 selected · actionClick · changed

SyGlobalHeader has three signals:

Qt capture · image
selected · actionClick · changed · Default
Default execution
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
        SyGlobalHeader {
            width: 760
            title: "Console"
            search: true; information: true; notification: true
            onSelected: (detail) => { if (true) { output.log(("selected: %1").arg(detail.tabkey)) } }
            onActionClick: (detail) => { if (true) { output.log(("actionClick: %1").arg(detail.type)) } }
            onChanged: (detail) => { if (true) { output.log(("changed: %1").arg(detail.value)) } }
            tabs: [
                SyTab { tabkey: "home"; text: "Home" },
                SyTab { tabkey: "data"; text: "Data" }
            ]
        }
        EventLog { id: output }
    }
}

04 setActiveTab · updateOverflowTabs

setActiveTab(index) makes the tab at that index the active one and emits selected({ tabkey, index }); it is ignored when the index is out of range or that tab is disabled (its own disabled, or the header's).

Qt capture · image
setActiveTab · updateOverflowTabs · Default
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

    Column {
        spacing: 24
        SyGlobalHeader { id: bar; width: 760; title: "Console"; tabs: [ SyTab { tabkey: "home"; text: "Home" }, SyTab { tabkey: "data"; text: "Data" }, SyTab { tabkey: "reports"; text: "Reports" } ] }
        Row {
            spacing: 8
            SyButton { id: exampleControl1;  visible: true; text: "bar.setActiveTab(1)"; variant: "secondary"; size: "small"; onClicked: bar.setActiveTab(1) }
            SyButton { id: exampleControl2;  visible: true; text: "bar.updateOverflowTabs()"; variant: "secondary"; size: "small"; onClicked: bar.updateOverflowTabs() }
        }
        Text {
            text: "bar.active === " + bar.active + "   bar.overflowTabs.length === " + bar.overflowTabs.length
            font.family: Theme.monoFontFamily
            font.pixelSize: 12
            color: Theme.semantic.textSubtle
        }
    }
}

05 Header with search

Header with search, configured with search.

Qt capture · image
Header with search · Result
Default execution
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 title: "Console"
        property bool search: true
        property bool information: true
        property bool notification: true
    }

    

    Column {
        spacing: 12
        SyGlobalHeader {
            width: 760
            title: storyArgs.title
            search: storyArgs.search
            information: storyArgs.information
            notification: storyArgs.notification
            onSelected: (detail) => output.log(detail.tabkey)
            tabs: [
                SyTab { tabkey: "home"; text: "Home" },
                SyTab { tabkey: "data"; text: "Data" },
                SyTab { tabkey: "reports"; text: "Reports" }
            ]
        }
        EventLog { id: output }
    }

}

06 Information and notifications

Information and notifications, configured with information, notification.

Qt capture · image
Information and notifications · Result
Default execution
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 title: "Console"
        property bool search: true
        property bool information: true
        property bool notification: true
    }

    

    Column {
        spacing: 12
        SyGlobalHeader {
            width: 760
            title: storyArgs.title
            search: storyArgs.search
            information: storyArgs.information
            notification: storyArgs.notification
            onSelected: (detail) => output.log(detail.tabkey)
            tabs: [
                SyTab { tabkey: "home"; text: "Home" },
                SyTab { tabkey: "data"; text: "Data" },
                SyTab { tabkey: "reports"; text: "Reports" }
            ]
        }
        EventLog { id: output }
    }

}

API 35

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

Properties

PropertyTypeDefaultDescription
string""The app name after the logo (16 px medium); hidden when empty
list—Items before the title
list—The SyTab headers (one, or a list in brackets)
list—Items at the right end, after the search field and the buttons
boolfalseThe 200 px search field; reports changed({ value })
boolfalseThe help button; reports actionClick({ type: "information" })
boolfalseThe bell button; reports actionClick({ type: "notification" })
int0The active tab's index; set it to switch silently, read it to know
boolfalseEvery tab, the search field, the information / notification buttons and the actions items inert
var[]The collected headers, in order (maintained by the header)
var[]The headers currently folded into the ··· menu

Additional properties

NameType / defaultDescription
Header width in logical pixels. Reduce it to test how tabs move into the overflow menu.

Methods

MethodDescription
Activates the tab at index and emits selected; ignored for an unknown index or a disabled tab
Lays the headers out again and refreshes overflowTabs; the header calls it on width and tab changes by itself

Signals

SignalArgumentsWhen
detail: { tabkey, index }A tab became active by a click, Space / Enter, the arrow keys, the ··· menu or setActiveTab(). Not when active is set from a binding, not for a disabled tab
detail: { type }The help ("information") or bell ("notification") button was clicked
detail: { value }The search field's text changed (every edit)

Behavior

ItemBehavior / conditions
Items before the title
The app name after the logo (16 px medium); hidden when empty
The 200 px search field; reports changed({ value })
The help button; reports actionClick({ type: "information" })
The bell button; reports actionClick({ type: "notification" })
Items at the right end, after the search field and the buttons
The SyTab headers (one, or a list in brackets)
The active tab's index; set it to switch silently, read it to know
Activates the tab at index and emits selected; ignored for an unknown index or a disabled tab
A tab became active by a click, Space / Enter, the arrow keys, the ··· menu or setActiveTab(). Not when active is set from a binding, not for a disabled tab
Every tab, the search field, the information / notification buttons and the actions items inert
The headers currently folded into the ··· menu
Lays the headers out again and refreshes overflowTabs; the header calls it on width and tab changes by itself
A closable header's × removes the header from the bar (the tab's own closed signal fires; the header itself has no close signal).
The search field's text changed (every edit)
The help ("information") or bell ("notification") button was clicked
Tab reaches the enabled headers, the search field, the buttons and the actions in order; on a focused header Left / Up and Right / Down move to the previous / next enabled tab (wrapping, activating it) and Space / Enter select it.

Keyboard

ItemBehavior / conditions
The SyTab headers (one, or a list in brackets)