├── LICENSE ├── QtCustomTitleBar ├── .gitignore ├── CMakeLists.txt ├── QtCustomTitleBar.pro ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── resources │ ├── icons │ │ ├── close.png │ │ ├── close_light.png │ │ ├── collapse_hide.png │ │ ├── collapse_hide_light.png │ │ ├── collapse_show.png │ │ ├── collapse_show_light.png │ │ ├── default_size.png │ │ ├── default_size_light.png │ │ ├── icon.png │ │ ├── maximize.png │ │ ├── maximize_light.png │ │ ├── minimize.png │ │ └── minimize_light.png │ ├── resources.qrc │ └── style │ │ └── appstyles.qss ├── windowframe.cpp ├── windowframe.h └── windowframe.ui └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 IVAN KALENSKY 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /QtCustomTitleBar/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | ui_* 20 | # Build results 21 | [Dd]ebug/ 22 | [Dd]ebugPublic/ 23 | [Rr]elease/ 24 | [Rr]eleases/ 25 | x64/ 26 | x86/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # StyleCop 66 | StyleCopReport.xml 67 | 68 | # Files built by Visual Studio 69 | *_i.c 70 | *_p.c 71 | *_h.h 72 | *.ilk 73 | *.meta 74 | *.obj 75 | *.iobj 76 | *.pch 77 | *.pdb 78 | *.ipdb 79 | *.pgc 80 | *.pgd 81 | *.rsp 82 | *.sbr 83 | *.tlb 84 | *.tli 85 | *.tlh 86 | *.tmp 87 | *.tmp_proj 88 | *_wpftmp.csproj 89 | *.log 90 | *.vspscc 91 | *.vssscc 92 | .builds 93 | *.pidb 94 | *.svclog 95 | *.scc 96 | 97 | # Chutzpah Test files 98 | _Chutzpah* 99 | 100 | # Visual C++ cache files 101 | ipch/ 102 | *.aps 103 | *.ncb 104 | *.opendb 105 | *.opensdf 106 | *.sdf 107 | *.cachefile 108 | *.VC.db 109 | *.VC.VC.opendb 110 | */build/ 111 | build 112 | 113 | # Visual Studio profiler 114 | *.psess 115 | *.vsp 116 | *.vspx 117 | *.sap 118 | 119 | # Visual Studio Trace Files 120 | *.e2e 121 | 122 | # TFS 2012 Local Workspace 123 | $tf/ 124 | 125 | # Guidance Automation Toolkit 126 | *.gpState 127 | 128 | # ReSharper is a .NET coding add-in 129 | _ReSharper*/ 130 | *.[Rr]e[Ss]harper 131 | *.DotSettings.user 132 | 133 | # TeamCity is a build add-in 134 | _TeamCity* 135 | 136 | # DotCover is a Code Coverage Tool 137 | *.dotCover 138 | 139 | # AxoCover is a Code Coverage Tool 140 | .axoCover/* 141 | !.axoCover/settings.json 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | 355 | .qtc_clangd/ 356 | debug/ 357 | release/ 358 | 359 | Makefile 360 | Makefile* 361 | .qmake.stash 362 | *.pro.user 363 | -------------------------------------------------------------------------------- /QtCustomTitleBar/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(QtCustomTitleBar VERSION 1.0 LANGUAGES C CXX) 3 | 4 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 5 | 6 | # Set up AUTOMOC and some sensible defaults for runtime execution 7 | # When using Qt 6.3, you can replace the code block below with 8 | # qt_standard_project_setup() 9 | set(CMAKE_AUTOMOC ON) 10 | include(GNUInstallDirs) 11 | set(CMAKE_AUTOUIC ON) 12 | 13 | find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core) 14 | find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Gui) 15 | find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Widgets) 16 | 17 | qt_add_executable(QtCustomTitleBar WIN32 MACOSX_BUNDLE 18 | main.cpp 19 | mainwindow.cpp mainwindow.h mainwindow.ui 20 | windowframe.cpp windowframe.h windowframe.ui 21 | ) 22 | target_link_libraries(QtCustomTitleBar PRIVATE 23 | Qt::Core 24 | Qt::Gui 25 | ) 26 | 27 | 28 | # Resources: 29 | set(resources_resource_files 30 | "resources/icons/close.png" 31 | "resources/icons/close_light.png" 32 | "resources/icons/collapse_hide.png" 33 | "resources/icons/collapse_hide_light.png" 34 | "resources/icons/collapse_show.png" 35 | "resources/icons/collapse_show_light.png" 36 | "resources/icons/default_size.png" 37 | "resources/icons/default_size_light.png" 38 | "resources/icons/icon.png" 39 | "resources/icons/maximize.png" 40 | "resources/icons/maximize_light.png" 41 | "resources/icons/minimize.png" 42 | "resources/icons/minimize_light.png" 43 | "resources/style/appstyles.qss" 44 | ) 45 | 46 | qt_add_resources(QtCustomTitleBar "resources" 47 | PREFIX 48 | "/recources" 49 | BASE 50 | "resources" 51 | FILES 52 | ${resources_resource_files} 53 | ) 54 | 55 | if((QT_VERSION_MAJOR GREATER 4)) 56 | target_link_libraries(QtCustomTitleBar PRIVATE 57 | Qt::Widgets 58 | ) 59 | endif() 60 | 61 | install(TARGETS QtCustomTitleBar 62 | BUNDLE DESTINATION . 63 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 64 | ) 65 | 66 | # Consider using qt_generate_deploy_app_script() for app deployment if 67 | # the project can use Qt 6.3. In that case rerun qmake2cmake with 68 | # --min-qt-version=6.3. 69 | -------------------------------------------------------------------------------- /QtCustomTitleBar/QtCustomTitleBar.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++17 6 | 7 | # You can make your code fail to compile if it uses deprecated APIs. 8 | # In order to do so, uncomment the following line. 9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 10 | 11 | SOURCES += \ 12 | main.cpp \ 13 | mainwindow.cpp \ 14 | windowframe.cpp 15 | 16 | HEADERS += \ 17 | mainwindow.h \ 18 | windowframe.h 19 | 20 | FORMS += \ 21 | mainwindow.ui \ 22 | windowframe.ui 23 | 24 | # Default rules for deployment. 25 | qnx: target.path = /tmp/$${TARGET}/bin 26 | else: unix:!android: target.path = /opt/$${TARGET}/bin 27 | !isEmpty(target.path): INSTALLS += target 28 | 29 | RESOURCES += \ 30 | resources/resources.qrc 31 | -------------------------------------------------------------------------------- /QtCustomTitleBar/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "windowframe.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | const QString style = "Fusion"; 10 | const QString appstylePath = ":/recources/style/appstyles.qss"; 11 | 12 | int main(int argc, char *argv[]){ 13 | QApplication a(argc, argv); 14 | a.setStyle(new QProxyStyle(QStyleFactory::create(style))); 15 | 16 | QFile styleFile(appstylePath); 17 | styleFile.open(QFile::ReadOnly); 18 | QString styleQSS = styleFile.readAll(); 19 | 20 | a.setStyleSheet(styleQSS); 21 | 22 | WindowFrame w(nullptr, new MainWindow()); 23 | w.setTitle("App title"); 24 | w.show(); 25 | return a.exec(); 26 | } 27 | -------------------------------------------------------------------------------- /QtCustomTitleBar/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | MainWindow::MainWindow(QWidget *parent) 9 | : QMainWindow(parent) 10 | , ui(new Ui::MainWindow){ 11 | 12 | ui->setupUi(this); 13 | 14 | this->statusBar()->setSizeGripEnabled(false); 15 | 16 | initTimer(); 17 | initMenuBar(); 18 | } 19 | 20 | MainWindow::~MainWindow(){ 21 | delete ui; 22 | } 23 | 24 | void MainWindow::initMenuBar(){ 25 | mMenuBar = new QMenuBar(); 26 | setMenuBar(mMenuBar); 27 | QMenu *settingsMenu = mMenuBar->addMenu(tr("&Settings")); 28 | 29 | QAction *exitAction = settingsMenu->addAction(tr("&Exit")); 30 | connect(exitAction, &QAction::triggered, this, &MainWindow::close); 31 | } 32 | 33 | void MainWindow::initTimer(){ 34 | const uint interval = 1000; 35 | 36 | QTimer *t = new QTimer(this); 37 | t->setInterval(interval); 38 | connect(t, &QTimer::timeout, [&]() { 39 | QString time1 = QTime::currentTime().toString(); 40 | ui->clock->setText(time1); 41 | } ); 42 | t->start(); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /QtCustomTitleBar/mainwindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class MainWindow; } 8 | QT_END_NAMESPACE 9 | 10 | class MainWindow : public QMainWindow 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | MainWindow(QWidget *parent = nullptr); 16 | ~MainWindow(); 17 | private: 18 | void initMenuBar(); 19 | void initTimer(); 20 | private: 21 | Ui::MainWindow *ui; 22 | QMenuBar *mMenuBar; 23 | }; 24 | -------------------------------------------------------------------------------- /QtCustomTitleBar/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 736 10 | 326 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | :/recources/icons/icon.png:/recources/icons/icon.png 19 | 20 | 21 | 22 | 23 | 24 | 25 | Qt::Vertical 26 | 27 | 28 | 29 | 20 30 | 40 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | Bahnschrift 40 | 54 41 | 42 | 43 | 44 | 45 | 46 | 47 | Qt::AlignCenter 48 | 49 | 50 | 51 | 52 | 53 | 54 | Qt::Vertical 55 | 56 | 57 | 58 | 20 59 | 40 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 0 71 | 0 72 | 736 73 | 21 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/close.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/close_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/close_light.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/collapse_hide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/collapse_hide.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/collapse_hide_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/collapse_hide_light.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/collapse_show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/collapse_show.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/collapse_show_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/collapse_show_light.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/default_size.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/default_size.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/default_size_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/default_size_light.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/icon.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/maximize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/maximize.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/maximize_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/maximize_light.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/minimize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/minimize.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/icons/minimize_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imitatehappiness/QtCustomTitleBar/6ca4b3b4fbc85a3d4cf30ed56a3d74431e502a0c/QtCustomTitleBar/resources/icons/minimize_light.png -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | style/appstyles.qss 4 | icons/close.png 5 | icons/minimize.png 6 | icons/maximize.png 7 | icons/icon.png 8 | icons/collapse_hide.png 9 | icons/collapse_show.png 10 | icons/default_size.png 11 | icons/close_light.png 12 | icons/collapse_hide_light.png 13 | icons/collapse_show_light.png 14 | icons/default_size_light.png 15 | icons/maximize_light.png 16 | icons/minimize_light.png 17 | 18 | 19 | -------------------------------------------------------------------------------- /QtCustomTitleBar/resources/style/appstyles.qss: -------------------------------------------------------------------------------- 1 | #MainWindow{ 2 | background-color: rgb(33, 33, 33); 3 | border-bottom: 2px solid rgb(33, 33, 33); 4 | border-bottom-left-radius: 10px; 5 | border-bottom-right-radius: 10px; 6 | } 7 | #body{ 8 | background-color: rgb(33, 33, 33); 9 | border-bottom: 2px rgb(33, 33, 33); 10 | border-bottom-left-radius: 10px; 11 | border-bottom-right-radius: 10px; 12 | } 13 | 14 | #header{ 15 | background-color: rgb(20, 20, 20); 16 | border: 1px solid rgb(20, 20, 20); 17 | border-top-left-radius: 10px; 18 | border-top-right-radius: 10px; 19 | } 20 | 21 | QPushButton { 22 | padding: 2px; 23 | margin: 2px; 24 | font: 10pt; 25 | background-color: rgb(20, 20, 20); 26 | color: #EEEEEE; 27 | border-radius: 4px; 28 | } 29 | 30 | QMenuBar{ 31 | background-color: #eee; 32 | color: rgb(70, 70, 70); 33 | } 34 | 35 | QPushButton:hover{ 36 | background-color: rgb(60, 60, 60); 37 | color: #EEEEEE; 38 | } 39 | 40 | QPushButton:pressed { 41 | border: 1px solid rgb(20, 20, 20); 42 | border-radius: 5px; 43 | } 44 | 45 | QPushButton#close:hover{ 46 | background-color: rgb(255, 50, 50); 47 | } 48 | 49 | QPushButton#close{ 50 | margin-right: 5px; 51 | } 52 | 53 | QLabel{ 54 | color: #eee; 55 | } 56 | 57 | QStatusBar{ 58 | background-color: rgb(20, 20, 20); 59 | border-bottom-left-radius: 10px; 60 | border-bottom-right-radius: 10px; 61 | } 62 | -------------------------------------------------------------------------------- /QtCustomTitleBar/windowframe.cpp: -------------------------------------------------------------------------------- 1 | #include "windowframe.h" 2 | #include "ui_windowframe.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | const QString title = "Custom Title Bar"; 10 | 11 | const QString headerDefaultStyle = QStringLiteral( 12 | "#header {" 13 | " background-color: rgb(20, 20, 20);" 14 | " border: 1px solid rgb(20, 20, 20);" 15 | " border-top-left-radius: 10px;" 16 | " border-top-right-radius: 10px;" 17 | "}" 18 | ); 19 | 20 | const QString headerCollapseStyle = QStringLiteral( 21 | "#header {" 22 | " background-color: rgb(20, 20, 20);" 23 | " border: 2px solid rgb(20, 20, 20);" 24 | " border-top-left-radius: 10px;" 25 | " border-top-right-radius: 10px;" 26 | " border-bottom-left-radius: 10px;" 27 | " border-bottom-right-radius: 10px;" 28 | "}" 29 | ); 30 | 31 | const QString headerMaximizeStyle = QStringLiteral( 32 | "#header {" 33 | " background-color: rgb(20, 20, 20);" 34 | " border: 1px solid rgb(20, 20, 20);" 35 | " border-top-left-radius: 0px;" 36 | " border-top-right-radius: 0px;" 37 | "}" 38 | ); 39 | 40 | const QString appIcon = ":/recources/icons/icon.png"; 41 | const QString closeIcon = ":/recources/icons/close_light.png"; 42 | const QString collapseHideIcon = ":/recources/icons/collapse_hide_light.png"; 43 | const QString collapseShowIcon = ":/recources/icons/collapse_show_light.png"; 44 | const QString maximizeIcon = ":/recources/icons/maximize_light.png"; 45 | const QString minimizeIcon = ":/recources/icons/minimize_light.png"; 46 | const QString defaultSizeIcon = ":/recources/icons/default_size_light.png"; 47 | 48 | /// @brief Constructor for the WindowFrame class. 49 | /// @param parent The parent widget. 50 | /// @param child The child widget to be added to the window (optional). 51 | WindowFrame::WindowFrame(QWidget *parent, QWidget *child) 52 | : QFrame(parent), ui(new Ui::WindowFrame){ 53 | 54 | ui->setupUi(this); 55 | mBorderSize = 5; 56 | 57 | initIcons(); 58 | 59 | ui->title->setText(title); 60 | 61 | setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint); 62 | setAttribute(Qt::WA_TranslucentBackground); 63 | if(child != nullptr) { 64 | ui->body->layout()->addWidget(child); 65 | mMainBody = child; 66 | mMainBody->installEventFilter(this); 67 | resize(child->size()); 68 | } 69 | mIsCollapse = false; 70 | } 71 | 72 | /// @brief Destructor for the WindowFrame class. 73 | WindowFrame::~WindowFrame(){ 74 | delete ui; 75 | } 76 | 77 | /// @brief Init frame icons. 78 | void WindowFrame::initIcons(){ 79 | this->setIcon(appIcon); 80 | 81 | ui->collapse->setIcon(QIcon(collapseHideIcon)); 82 | ui->close->setIcon(QIcon(closeIcon)); 83 | ui->maximum->setIcon(QIcon(maximizeIcon)); 84 | ui->minimum->setIcon(QIcon(minimizeIcon)); 85 | } 86 | 87 | /// @brief Show header menu. 88 | /// @param pos position mouse click. 89 | void WindowFrame::showHeaderContextMenu(const QPoint &pos){ 90 | QMenu contextMenu(this); 91 | 92 | QAction *exitAction = contextMenu.addAction(tr("&Exit")); 93 | connect(exitAction, &QAction::triggered, this, &WindowFrame::close); 94 | 95 | contextMenu.addAction(exitAction); 96 | contextMenu.exec(mapToGlobal(pos)); 97 | } 98 | 99 | /// @brief Handler for the "Close" button click signal. 100 | void WindowFrame::on_close_clicked(){ 101 | close(); 102 | } 103 | 104 | /// @brief Handler for the "Maximize/Restore" button click signal. 105 | void WindowFrame::on_maximum_clicked(){ 106 | if(isMaximized()) { 107 | ui->maximum->setIcon(QIcon(maximizeIcon)); 108 | mIsCollapse ? ui->header->setStyleSheet(headerCollapseStyle) : ui->header->setStyleSheet(headerDefaultStyle); 109 | showNormal(); 110 | } else { 111 | ui->maximum->setIcon(QIcon(defaultSizeIcon)); 112 | ui->header->setStyleSheet(headerMaximizeStyle); 113 | showMaximized(); 114 | } 115 | } 116 | 117 | /// @brief Handler for the "Minimize" button click signal. 118 | void WindowFrame::on_minimum_clicked(){ 119 | showMinimized(); 120 | } 121 | 122 | /// @brief Handler for the "Collapse" button click signal. 123 | void WindowFrame::on_collapse_clicked() { 124 | if (mIsCollapse) { 125 | ui->body->setVisible(true); 126 | mIsCollapse = false; 127 | ui->collapse->setIcon(QIcon(collapseHideIcon)); 128 | isMaximized() ? ui->header->setStyleSheet(headerMaximizeStyle) : ui->header->setStyleSheet(headerDefaultStyle); 129 | } else { 130 | ui->body->setVisible(false); 131 | mIsCollapse = true; 132 | ui->collapse->setIcon(QIcon(collapseShowIcon)); 133 | isMaximized() ? ui->header->setStyleSheet(headerMaximizeStyle) : ui->header->setStyleSheet(headerCollapseStyle); 134 | } 135 | } 136 | 137 | 138 | /// @brief Handler for the mouse press event. 139 | /// @param event Pointer to the QMouseEvent object containing event information. 140 | void WindowFrame::mousePressEvent(QMouseEvent *event) { 141 | #if QT_VERSION_MAJOR < 6 142 | if (event->buttons() == Qt::LeftButton) { 143 | QWidget* widget = childAt(event->x(), event->y()); 144 | if(widget == ui->LHeader || widget == ui->title || widget == ui->icon) { 145 | mPosition.setX(event->x()); 146 | mPosition.setY(event->y()); 147 | } 148 | } 149 | if (event->button() == Qt::RightButton ) { 150 | QWidget* widget = childAt(event->x(), event->y()); 151 | if (widget == ui->LHeader || widget == ui->title || widget == ui->icon){ 152 | showHeaderContextMenu(event->pos()); 153 | } 154 | } 155 | #else 156 | if (event->buttons() == Qt::LeftButton) { 157 | QWidget* widget = childAt(event->position().x(), event->position().y()); 158 | if(widget == ui->LHeader || widget == ui->title || widget == ui->icon) { 159 | mPosition.setX(event->position().x()); 160 | mPosition.setY(event->position().y()); 161 | } 162 | } 163 | if (event->button() == Qt::RightButton ) { 164 | QWidget* widget = childAt(event->position().x(), event->position().y()); 165 | if (widget == ui->LHeader || widget == ui->title || widget == ui->icon){ 166 | showHeaderContextMenu(event->pos()); 167 | } 168 | } 169 | 170 | #endif 171 | } 172 | 173 | /// @brief Handler for the mouse move event within the window. 174 | /// @param event Pointer to the mouse move event object (QMouseEvent). 175 | /// @return No return value. 176 | void WindowFrame::mouseMoveEvent(QMouseEvent *event) { 177 | if (event->buttons() == Qt::LeftButton) { 178 | #if QT_VERSION_MAJOR < 6 179 | if (mPosition.x() != 0 || mPosition.y() != 0) { 180 | move(event->globalX() - mPosition.x(), event->globalY() - mPosition.y()); 181 | } 182 | #else 183 | if (mPosition.x() != 0 || mPosition.y() != 0) { 184 | move(event->globalPosition().x() - mPosition.x(), event->globalPosition().x() - mPosition.y()); 185 | } 186 | #endif 187 | } 188 | } 189 | 190 | /// @brief Handler for the mouse release event within the window. 191 | /// @param event Pointer to the mouse release event object (QMouseEvent). 192 | void WindowFrame::mouseReleaseEvent(QMouseEvent *event) { 193 | Q_UNUSED(event); 194 | mPosition.setX(0); 195 | mPosition.setY(0); 196 | } 197 | 198 | /// @brief Handler for the mouse double-click event within the window. 199 | /// @param event Pointer to the mouse double-click event object (QMouseEvent). 200 | void WindowFrame::mouseDoubleClickEvent(QMouseEvent *event) { 201 | if (event->buttons() == Qt::LeftButton) { 202 | #if QT_VERSION_MAJOR < 6 203 | QWidget* widget = childAt(event->x(), event->y()); 204 | #else 205 | QWidget* widget = childAt(event->position().x(), event->position().x()); 206 | #endif 207 | if(widget == ui->LHeader) { 208 | if(isMaximized()) { 209 | ui->maximum->setIcon(QIcon(maximizeIcon)); 210 | ui->header->setStyleSheet(headerDefaultStyle); 211 | showNormal(); 212 | } else { 213 | ui->maximum->setIcon(QIcon(defaultSizeIcon)); 214 | ui->header->setStyleSheet(headerMaximizeStyle); 215 | showMaximized(); 216 | } 217 | } 218 | } 219 | } 220 | 221 | /// @brief Handler for the native window event. 222 | /// @param eventType The type of event, as a byte array (QByteArray). 223 | /// @param message Pointer to a structure containing event information (void*). 224 | /// @param result Pointer to a variable for returning the result (long*). 225 | /// @return The return value, true if the event was handled, otherwise false. 226 | // Add support for Qt 6 227 | #if QT_VERSION_MAJOR < 6 228 | bool WindowFrame::nativeEvent(const QByteArray &eventType, void *message, long *result) 229 | #else 230 | bool WindowFrame::nativeEvent(const QByteArray &eventType, void *message, qint64 *result) 231 | #endif 232 | { 233 | Q_UNUSED(eventType) 234 | MSG *param = static_cast(message); 235 | 236 | if (param->message == WM_NCHITTEST) { 237 | QPoint globalPos(GET_X_LPARAM(param->lParam), GET_Y_LPARAM(param->lParam)); 238 | QPoint localPos = mapFromGlobal(globalPos); 239 | 240 | int nX = localPos.x(); 241 | int nY = localPos.y(); 242 | 243 | if (nX >= 0 && nX < mBorderSize) { 244 | if (nY >= 0 && nY < mBorderSize) { 245 | *result = HTTOPLEFT; 246 | } else if (nY >= height() - mBorderSize) { 247 | *result = HTBOTTOMLEFT; 248 | } else { 249 | *result = HTLEFT; 250 | } 251 | } else if (nX >= width() - mBorderSize) { 252 | if (nY >= 0 && nY < mBorderSize) { 253 | *result = HTTOPRIGHT; 254 | } else if (nY >= height() - mBorderSize) { 255 | *result = HTBOTTOMRIGHT; 256 | } else { 257 | *result = HTRIGHT; 258 | } 259 | } else if (nY >= 0 && nY < mBorderSize) { 260 | *result = HTTOP; 261 | } else if (nY >= height() - mBorderSize) { 262 | *result = HTBOTTOM; 263 | } else { 264 | return QWidget::nativeEvent(eventType, message, result); 265 | } 266 | 267 | return true; 268 | } 269 | 270 | return QWidget::nativeEvent(eventType, message, result); 271 | } 272 | 273 | /// @brief Show or hide the window minimization button. 274 | /// @param enable If true, the button will be shown; if false, it will be hidden. 275 | void WindowFrame::enableMinimum(bool enable) { 276 | !enable ? ui->minimum->hide() : ui->minimum->show(); 277 | } 278 | 279 | /// @brief Show or hide the window maximization button. 280 | /// @param enable If true, the button will be shown; if false, it will be hidden. 281 | void WindowFrame::enableMaximum(bool enable) { 282 | !enable ? ui->maximum->hide() : ui->maximum->show(); 283 | } 284 | 285 | /// @brief Show or hide the window close button. 286 | /// @param enable If true, the button will be shown; if false, it will be hidden. 287 | void WindowFrame::enableClose(bool enable) { 288 | !enable ? ui->close->hide() : ui->close->show(); 289 | } 290 | 291 | /// @brief set window icon 292 | /// @param iconPath - path to icon file 293 | void WindowFrame::setIcon(const QString &iconPath) { 294 | QPixmap pixmap(iconPath); 295 | ui->icon->setPixmap(pixmap); 296 | ui->icon->setScaledContents(true); 297 | ui->icon->setAlignment(Qt::AlignCenter); 298 | ui->icon->resize(24, 24); 299 | } 300 | 301 | /// @brief set title for the window 302 | /// @param title 303 | void WindowFrame::setTitle(const QString &title) { 304 | ui->title->setText(title); 305 | this->setWindowTitle(title); 306 | } 307 | 308 | /// @brief Override event filtering function for the WindowFrame class. 309 | /// @param obj Pointer to the object for which the event was generated. 310 | /// @param event Pointer to the QEvent object representing the event. 311 | /// @return `true` if the event was handled, otherwise `false`. 312 | bool WindowFrame::eventFilter(QObject *obj, QEvent *event) { 313 | if(obj == mMainBody) { 314 | if(event->type() == QEvent::HideToParent) { 315 | hide(); 316 | return true; 317 | } 318 | if(event->type() == QEvent::ShowToParent) { 319 | show(); 320 | return true; 321 | } 322 | return QObject::eventFilter(obj, event); 323 | } else { 324 | return QFrame::eventFilter(obj, event); 325 | } 326 | return false; 327 | } 328 | 329 | 330 | -------------------------------------------------------------------------------- /QtCustomTitleBar/windowframe.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class WindowFrame; 9 | } 10 | 11 | class WindowFrame : public QFrame { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit WindowFrame(QWidget *parent = nullptr, QWidget *child = nullptr); 16 | ~WindowFrame(); 17 | 18 | public: 19 | /// Init frame icons 20 | void initIcons(); 21 | /// Show header menu. 22 | void showHeaderContextMenu(const QPoint &pos); 23 | /// Show or hide the window minimization button. 24 | void enableMinimum(bool enable); 25 | /// Show or hide the window maximization button. 26 | void enableMaximum(bool enable); 27 | /// Show or hide the window close button. 28 | void enableClose(bool enable); 29 | /// set window icon 30 | void setIcon(const QString& iconPath); 31 | /// set window title 32 | void setTitle(const QString& title); 33 | protected: 34 | /// Handler for the mouse press event. 35 | void mousePressEvent(QMouseEvent *event) override; 36 | /// Handler for the mouse move event within the window. 37 | void mouseMoveEvent(QMouseEvent *event) override; 38 | /// Handler for the mouse release event within the window. 39 | void mouseReleaseEvent(QMouseEvent *event) override; 40 | /// Handler for the mouse double-click event within the window. 41 | void mouseDoubleClickEvent(QMouseEvent *event) override; 42 | /// Handler for the native window event. 43 | // Add support for Qt 6 44 | #if QT_VERSION_MAJOR < 6 45 | bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; 46 | #else 47 | bool nativeEvent(const QByteArray &eventType, void *message, qint64 *result) override; 48 | #endif 49 | /// Override event filtering function for the WindowFrame class. 50 | bool eventFilter(QObject *obj, QEvent *event) override; 51 | 52 | private slots: 53 | /// Handler for the "Close" button click signal. 54 | void on_close_clicked(); 55 | /// Handler for the "Maximize/Restore" button click signal. 56 | void on_maximum_clicked(); 57 | /// Handler for the "Minimize" button click signal. 58 | void on_minimum_clicked(); 59 | /// Handler for the "Collapse" button click signal. 60 | void on_collapse_clicked(); 61 | 62 | private: 63 | /// Pointer to the user interface object. 64 | Ui::WindowFrame *ui; 65 | /// Pointer to the main widget (child widget). 66 | QWidget *mMainBody; 67 | /// Window mPosition on the screen. 68 | QPoint mPosition; 69 | /// Size of the window borders for resize. 70 | int mBorderSize; 71 | /// Collapse flag. 72 | bool mIsCollapse; 73 | }; 74 | 75 | -------------------------------------------------------------------------------- /QtCustomTitleBar/windowframe.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | WindowFrame 4 | 5 | 6 | 7 | 0 8 | 0 9 | 857 10 | 563 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | :/recources/icons/icon.png:/recources/icons/icon.png 25 | 26 | 27 | 28 | 29 | 30 | 31 | 0 32 | 33 | 34 | 0 35 | 36 | 37 | 0 38 | 39 | 40 | 0 41 | 42 | 43 | 0 44 | 45 | 46 | 47 | 48 | QFrame::NoFrame 49 | 50 | 51 | QFrame::Raised 52 | 53 | 54 | 55 | 0 56 | 57 | 58 | 0 59 | 60 | 61 | 0 62 | 63 | 64 | 0 65 | 66 | 67 | 0 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 0 77 | 78 | 79 | 0 80 | 81 | 82 | 0 83 | 84 | 85 | 0 86 | 87 | 88 | 0 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 16777215 101 | 28 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 0 110 | 111 | 112 | 0 113 | 114 | 115 | 0 116 | 117 | 118 | 0 119 | 120 | 121 | 122 | 123 | 124 | 0 125 | 126 | 127 | 0 128 | 129 | 130 | 0 131 | 132 | 133 | 0 134 | 135 | 136 | 0 137 | 138 | 139 | 140 | 141 | Qt::Horizontal 142 | 143 | 144 | QSizePolicy::Fixed 145 | 146 | 147 | 148 | 10 149 | 20 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 16 159 | 16 160 | 161 | 162 | 163 | 164 | 16 165 | 16 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | color: #eee; margin-left:5px; 180 | 181 | 182 | Custom Title Bar 183 | 184 | 185 | 186 | 187 | 188 | 189 | Qt::Horizontal 190 | 191 | 192 | 193 | 419 194 | 18 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 0 204 | 0 205 | 206 | 207 | 208 | 209 | 42 210 | 28 211 | 212 | 213 | 214 | 215 | 42 216 | 28 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 0 229 | 0 230 | 231 | 232 | 233 | 234 | 42 235 | 28 236 | 237 | 238 | 239 | 240 | 42 241 | 28 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 16 253 | 16 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 0 263 | 0 264 | 265 | 266 | 267 | 268 | 42 269 | 28 270 | 271 | 272 | 273 | 274 | 42 275 | 28 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 16 287 | 16 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 0 297 | 0 298 | 299 | 300 | 301 | 302 | 42 303 | 28 304 | 305 | 306 | 307 | 308 | 42 309 | 28 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 16 321 | 16 322 | 323 | 324 | 325 | 326 | 327 | title 328 | icon 329 | collapse 330 | minimum 331 | maximum 332 | close 333 | horizontalSpacer 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # Custom Title Bar Template for C++ Qt 6 | 7 | ![GitHub stars](https://img.shields.io/github/stars/imitatehappiness/QtCustomTitleBar?style=social) 8 | ![GitHub forks](https://img.shields.io/github/forks/imitatehappiness/QtCustomTitleBar?style=social) 9 | 10 | ![Qt version](https://img.shields.io/badge/Qt-5.15.2-151515.svg?Color=EEE&logoColor=EEE) 11 | ![MinGW version](https://img.shields.io/badge/MinGW-5.3.0-151515.svg?Color=EEE&logoColor=EEE) 12 | 13 | # About project 14 | In standard C++/Qt applications, the window's title bar is managed by the operating system, which imposes limitations on customization. 15 | 16 | This repository provides a template for creating a custom title bar in a C++ Qt application. The custom title bar replicates essential window functionality, including hiding, dragging, maximizing, and closing the window. It serves as an excellent starting point for developers looking to design a more personalized and visually appealing title bar for their Qt applications. 17 | 18 | ## Features 19 | ### 1. Interactive Window Controls 20 | - **Collapse Button**: Toggles between collapsing and expanding the window body. 21 | - **Minimize Button**: Minimizes the window to the taskbar. 22 | - **Maximize/Restore Button**: Allows the window to switch between maximized and normal states. 23 | - **Close Button**: Closes the window. 24 | 25 | ### 2. Draggable Header 26 | - **Move Window**: The window can be dragged and moved around the screen by clicking and holding the left mouse button on the header. 27 | - **Double-Click to Maximize/Restore**: Double-clicking the header toggles between maximized and restored states. 28 | 29 | ### 3. Context Menu 30 | - **Right-Click Menu on Header**: Right-clicking the header brings up a context menu. 31 | 32 |
33 | Preview 34 |

35 | 36 |

37 |
38 | 39 | ## Basic usage 40 | 41 | ``` C++ 42 | #include "mainwindow.h" 43 | #include "windowframe.h" 44 | 45 | #include 46 | 47 | int main(int argc, char *argv[]){ 48 | QApplication a(argc, argv); 49 | 50 | WindowFrame w(nullptr, new MainWindow()); 51 | w.show(); 52 | return a.exec(); 53 | 54 | } 55 | ``` 56 | ## UI Demonstration 57 | 58 |

59 |

61 | 62 | 63 | --------------------------------------------------------------------------------