Skip to content

Commit

Permalink
Fix frameless window on macOS in Qt 6.8 (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttyartist authored and guihkx committed Oct 25, 2024
1 parent bfb0827 commit 012c159
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/framelesswindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ - (void)zoomButtonAction:(id)sender
return;
}

// Since Qt 6.8 we need this to ask the QLayout to ignore the contents margins to make the
// window frameless on macOS
setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false);

AppObserver *observer = [[AppObserver alloc] init];
if (observer) {
observer.window = this;
Expand Down
6 changes: 6 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ void MainWindow::setupMainWindow()
setAttribute(Qt::WA_TranslucentBackground);
#endif

#if defined(Q_OS_MAC)
// Since Qt 6.8 we need this to ask the QLayout to ignore the contents margins to make the
// window frameless on macOS
ui->centralWidget->setAttribute(Qt::WA_LayoutOnEntireRect, true);
#endif

// load stylesheet
QFile mainWindowStyleFile(QStringLiteral(":/styles/main-window.css"));
mainWindowStyleFile.open(QFile::ReadOnly);
Expand Down

0 comments on commit 012c159

Please sign in to comment.