From 129c32448fa36482c46ae9645e18a62722a04e53 Mon Sep 17 00:00:00 2001 From: SineStriker <trueful@163.com> Date: 周三, 06 12月 2023 18:27:56 +0800 Subject: [PATCH] Revert "fix mem leak" --- examples/mainwindow/mainwindow.cpp | 36 +++++++++++++++++++++++++++++++++--- 1 files changed, 33 insertions(+), 3 deletions(-) diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp index 65c4b12..adcf6cd 100644 --- a/examples/mainwindow/mainwindow.cpp +++ b/examples/mainwindow/mainwindow.cpp @@ -32,8 +32,7 @@ void MainWindow::installWindowAgent() { auto agent = new QWK::WidgetWindowAgent(this); if (!agent->setup(this)) { - qDebug() << "Frameless handle failed to initialize."; - return; + qFatal("Frameless handle failed to initialize."); } auto titleLabel = new QLabel(); @@ -54,11 +53,42 @@ return menuBar; }(); + static const auto buttonStyleSheet = QLatin1String{ R"( +QPushButton { + background-color:white; + color:black; +} +QPushButton:hover { + background-color:black; + color:white; +} +QPushButton:pressed { + background-color:red; + color:white; +} +)" }; + auto iconButton = new QPushButton("I"); + iconButton->setFlat(true); + iconButton->setAttribute(Qt::WA_Hover); + iconButton->setMouseTracking(true); + iconButton->setStyleSheet(buttonStyleSheet); auto minButton = new QPushButton("鈥�"); + minButton->setFlat(true); + minButton->setAttribute(Qt::WA_Hover); + minButton->setMouseTracking(true); + minButton->setStyleSheet(buttonStyleSheet); auto maxButton = new QPushButton("馃棖"); maxButton->setCheckable(true); + maxButton->setFlat(true); + maxButton->setAttribute(Qt::WA_Hover); + maxButton->setMouseTracking(true); + maxButton->setStyleSheet(buttonStyleSheet); auto closeButton = new QPushButton("鉁�"); + closeButton->setFlat(true); + closeButton->setAttribute(Qt::WA_Hover); + closeButton->setMouseTracking(true); + closeButton->setStyleSheet(buttonStyleSheet); auto windowBar = new QWK::WindowBar(); windowBar->setIconButton(iconButton); @@ -92,5 +122,5 @@ setMenuWidget(windowBar); setCentralWidget(clockWidget); setWindowTitle("Example MainWindow"); - resize(1024, 768); + resize(640, 480); } -- Gitblit v1.9.1