From 0b3972643d8228acdc79f5540dc7e3d0aa48e9da Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Tue, 19 May 2020 10:20:34 +0800 Subject: [PATCH] Minor tweaks. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- main_unix.cpp | 2 +- main_windows.cpp | 2 +- resources/qml/main.qml | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main_unix.cpp b/main_unix.cpp index 1a5c336..0d115f0 100644 --- a/main_unix.cpp +++ b/main_unix.cpp @@ -32,7 +32,6 @@ int main(int argc, char *argv[]) { QWidget widget; widget.setContentsMargins(0, 0, 0, 0); QLabel *label = new QLabel; - label->setText(QObject::tr("Hello, World!")); QObject::connect(&widget, &QWidget::windowTitleChanged, label, &QLabel::setText); QPushButton *minimizeButton = new QPushButton; @@ -70,6 +69,7 @@ int main(int argc, char *argv[]) { mainLayout->addLayout(tbLayout); mainLayout->addStretch(); widget.setLayout(mainLayout); + widget.setWindowTitle(QObject::tr("Hello, World!")); helper.setIgnoreObjects(&widget, {minimizeButton, maximizeButton, closeButton}); helper.removeWindowFrame(&widget); diff --git a/main_windows.cpp b/main_windows.cpp index 7321f8f..447ada1 100644 --- a/main_windows.cpp +++ b/main_windows.cpp @@ -43,7 +43,6 @@ int main(int argc, char *argv[]) { QWidget widget; widget.setContentsMargins(0, 0, 0, 0); QLabel *label = new QLabel; - label->setText(QObject::tr("Hello, World!")); QObject::connect(&widget, &QWidget::windowTitleChanged, label, &QLabel::setText); QPushButton *minimizeButton = new QPushButton; @@ -81,6 +80,7 @@ int main(int argc, char *argv[]) { mainLayout->addLayout(tbLayout); mainLayout->addStretch(); widget.setLayout(mainLayout); + widget.setWindowTitle(QObject::tr("Hello, World!")); const auto hWnd_widget = reinterpret_cast(widget.winId()); WinNativeEventFilter::addFramelessWindow(hWnd_widget); const auto data_widget = WinNativeEventFilter::windowData(hWnd_widget); diff --git a/resources/qml/main.qml b/resources/qml/main.qml index b74d1e2..597c255 100644 --- a/resources/qml/main.qml +++ b/resources/qml/main.qml @@ -11,12 +11,11 @@ Window { FramelessHelper { id: framelessHelper - Component.onCompleted: framelessHelper.removeWindowFrame() } Rectangle { id: titleBar - height: 30 + height: framelessHelper.titleBarHeight color: "white" anchors.top: parent.top anchors.left: parent.left @@ -75,4 +74,6 @@ Window { anchors.left: parent.left anchors.right: parent.right } + + Component.onCompleted: framelessHelper.removeWindowFrame() }