๐๐ป QT QML์์ ์๋์ฐ ๊ตฌํ์ ์ดํ๋ฆฌ์ผ์ด์
์๋์ฐ ํ์
๊ณผ ์๋์ฐ ํ์
์ ๋ํ ์ค๋ช
์
๋๋ค.
This is a description of application window types and window types when implementing windows in QT QML.
๐๐ป Window :
โ๏ธ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ์๋์ฐ ์ปจํ
์ด๋. ๋จ์ ์ฐฝ์ผ๋ก, ๋ฉ๋ด, ํด๋ฐ, ์ํ๋ฐ ๋ฑ ๊ณ ๊ธ UI ๊ตฌ์ฑ ์์๋ ์์ต๋๋ค.
The most basic window container. It’s a simple window, lacking advanced UI elements like menus, toolbars, or status bars.
โ๏ธ ์๋์ฐ๋ ๊ฒ์, ์๋ฎฌ๋ ์ด์
, ๋จ์ ๋๊ตฌ UI, ํ์
์ ๊ตฌํํ๋ ๊ฒฝ์ฐ ์ฌ์ฉํฉ๋๋ค.
Windows is used for implementing games, simulations, simple tool UIs, and pop-ups.
๐๐ป ApplicationWindow :
โ๏ธ Window๋ฅผ ์์๋ฐ์ Qt Quick Controls 2์์ ์ ๊ณตํ๋ ๋ฉ๋ด๋ฐ, ํด๋ฐ, ์ํ๋ฐ ๋ฑ์ ์ฝ๊ฒ ์ฌ์ฉํ ์ ์๋๋ก ํ์ฅ๋ ์๋์ฐ ํ์
์
๋๋ค.
This is an extended window type that inherits from Window and allows easy use of menu bars, toolbars, status bars, etc. provided by Qt Quick Controls 2.
โ๏ธ ์ดํ๋ฆฌ์ผ์ด์
์๋์ฐ๋ ์ผ๋ฐ ๋ฐ์คํฌํ ์ฑ, ๋ฉ๋ด/ํด๋ฐ/์ํ๋ฐ ํ์๋ก ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๋ macOS ์์คํ
๋ฉ๋ด ์ฐ๋ ํ์ํ ๊ฒฝ์ฐ์ ์ฌ์ฉํฉ๋๋ค.
Application windows are used when general desktop apps require menus/toolbars/status bars, or when macOS system menu integration is required.
๐๐ป MacOS ๋ฉ๋ด ํน์ง / MacOS Menu Features
โ๏ธMacOS์์๋ ์๋์ ์ฌ์ง์ฒ๋ผ ํ๋ก๊ทธ๋จ์ ๋ฉ๋ด๋ ์๋์ฐ์ ๋ถ์ด ์์ต๋๋ค.
On MacOS, the program’s menu is attached to the window, as shown in the picture below.

โ๏ธ MacOS์ ์์คํ
๋ฉ๋ด์ ์ถฉ๋ํ๋ ๊ฒฝ์ฐ ๋ฉ๋ด๊ฐ ๋ํ๋์ง ์์ ์ ์์ต๋๋ค.
If there is a conflict with the system menu of macOS, the menu may not appear.
๐๐ป ์๋์ฐ ํ์
๊ณผ ์ดํ๋ฆฌ์ผ์ด์
์ ์ฐจ์ด์
Differences between Windows types and applications
| ํญ๋ชฉ / Item | Window | ApplicationWindow |
|---|---|---|
| menuBar ์ง์ menuBar support | ์์ / No | ์์ (menuBar ์์ฑ)Yes (menuBar property) |
| toolBar ์ง์ toolBar support | ์์ / No | ์์ (toolBar ์์ฑ)Yes (toolBar property) |
| statusBar ์ง์ statusBar support | ์์ / No | ์์ (statusBar ์์ฑ)Yes (statusBar property) |
| ๋ ์ด์์ Layout | ๋จ์ / Simple | ๋ฉ๋ด/ํด๋ฐ/์ํ๋ฐ๊ฐ ๋ ์ด์์์ ์๋ ๋ฐฐ์น๋จ Menu/ToolBar/StatusBar automatically managed |
| ๊ธฐ๋ณธ ์ปจํธ๋กค Built-in controls | ์์ / No | Qt Quick Controls 2 ์ปดํฌ๋ํธ์ ํธํ ์ต์ ํ Optimized for Qt Quick Controls 2 components |
| macOS ๋ฉ๋ด๋ฐ macOS system menu | ์์คํ
๋ฉ๋ด๋ฐ์ ์ฐ๋ ๋ถ๊ฐ๋ฅํจ Not supported | macOS ์์คํ
๋ฉ๋ด๋ฐ์ ์๋ ์ฐ๋ Automatically integrated with macOS system menu bar |
| ์๋์ฐ ๋ด๋ถ ๋ฉ๋ด Internal window menu | ๊ตฌํ ํ์ Must be implemented manually | menuBar ์์ฑ ์ฌ์ฉ ๊ฐ๋ฅ Available via menuBar property |
๐๐ป ์ฝ๋ / Code
โ๏ธ ์๋๋ ์๋์ฐ ํ์
๊ณผ ์ดํ๋ฆฌ์ผ์ด์
์๋์ฐ ํ์
์์ ๋ฉ๋ด๋ฅผ ๊ตฌํํ๋ ์ฝ๋์
๋๋ค.
Below is the code that implements the menu in the window type and application window type.
โ๏ธ์๋์ฐ ํ์
์์๋ ๋ฉ๋ด๋ฅผ ๊ตฌํํด์ผํ๋ฉฐ MacOS์ ํธํ๋์ง ์์ต๋๋ค.
The Windows type requires the implementation of a menu and is not compatible with MacOS.
โ๏ธMain.qml
import QtQuick
import QtQuick.Controls
Window {
width: 640
height: 480
visible: true
title: qsTr("Window")
Column {
anchors.fill: parent
Rectangle {
color:"lightblue"
width:parent.width
height:30 // ๋์ด ์ง์ ํ์ง ์์ผ๋ฉด Recangle์ด ์๋ณด์ / Recangle is not visible if height is not specified
Row{
anchors.left: parent.left // Row์ ์ผ์ชฝ์ column์ ์ผ์ชฝ์ ๋ง์ถ๊ธฐ / Align the left side of the row to the left side of the column
anchors.leftMargin: 10 // ์ข์ธก ๊ฐ๊ฒฉ
anchors.verticalCenter: parent.verticalCenter // ์์ง ์ค์ ์ ๋ ฌ / vertical center alignment
spacing : 20 // Row์์ ์๋ ์์ดํ
๋ค์ ๊ฐ๊ฒฉ / Spacing between items in a row
Text {
id:fileText
text: "File"
color: "#333"
MouseArea {
// ๋ง์ฐ์ค ํด๋ฆญ ์์ญ์ Text์ ์ฒด๋ก ์ค์
// Set the mouse click area to the entire text
anchors.fill: parent
onClicked: fileMenu.open(fileText)
}
}
Text {
id:editText
text: "Edit";
color: "#333"
MouseArea {
anchors.fill : parent
onClicked: editMenu.open(editText)
}
}
}
}
Text{
text : "Window"
font.pixelSize: 25
anchors.centerIn: parent
}
// File ๋ฉ๋ด / File Menu
Menu {
id: fileMenu
title: "File"
MenuItem { text: "New" }
MenuItem { text: "Open..." }
MenuItem { text: "Save" }
MenuItem {
text: "Open ApplicatioonWindow"
onTriggered: {
// ์์ฐฝ ๋์ฐ๊ธฐ,ApplicationWindow.qml ๋ถ๋ฌ์ค๊ธฐ
// Open a new window, load ApplicationWindow.qml
var component = Qt.createComponent("ApplicationWindow.qml")
if (component.status === Component.Ready) {
var newWin = component.createObject(null) // parent ์์ด ์ ์ฐฝ / New window without parent
if (newWin) newWin.visible = true
} else {
console.log("Error loading component:", component.errorString())
}
}
}
MenuItem { text: "Exit" }
}
// Edit ๋ฉ๋ด / Edit Menu
Menu {
id: editMenu
title: "Edit"
MenuItem { text: "Copy" }
MenuItem { text: "Paste" }
MenuItem { text: "Cut" }
}
}
}
๐๐ป ApplicationWindow.qml
โ๏ธ ์ดํ๋ฆฌ์ผ์ด์
์๋์ฐ ํ์
์์๋ ๋ฉ๋ด๋ฑ์ ๊ตฌํํ๊ธฐ๊ฐ ์ฝ๊ณ MacOS์ ๋ฉ๋ดํธํ์ด ๊ฐ๋ฅํฉ๋๋ค.
In the application window type, it is easy to implement menus, etc., and menu compatibility with MacOS is possible.
import QtQuick
import QtQuick.Controls
ApplicationWindow {
width: 400
height: 300
visible: true
menuBar: MenuBar {
Menu {
title: "File"
MenuItem { text: "Open" }
MenuItem { text: "Close window"; onTriggered: Qt.quit() } //real exit
MenuItem { text: "Exit" } // macOS์์๋ ์๋ํ๋จ / It doesn't appear on macOS
}
}
Column{
anchors.fill: parent
Text{
text: "Application Window"
font.pixelSize: 25
anchors.centerIn: parent
}
}
}
๐๐ป ์คํฌ๋ฆฐ ์ท / ScreenShot