Jump to content

Qt for HarmonyOS/qtohosextras doc/Window Corner Radius Example

From Qt Wiki
Revision as of 07:56, 17 September 2026 by Shawn Luo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Window Corner Radius Example

Demonstrates setting rounded corners on a Qt window.


The main window contains a spin box for the radius and a button that creates a new sub window. The radius is applied with QtOhosExtras::setWindowCornerRadius() immediately before the new window is shown.

             auto *newWindow = new QWidget(window);
             newWindow->setWindowFlags(Qt::Window);
             newWindow->setWindowTitle(QLatin1String("OHOS corner radius window"));
             newWindow->resize(QSize{300, 300});
             QtOhosExtras::setWindowCornerRadius(newWindow, spinbox->value());

             newWindow->show();

Note: The radius has to be applied before the window is shown, and the target must be a sub or floating window (for example created with the Qt::Window flag or marked with QtOhosExtras::setShowWindowAsFloatWindowHint()). Negative values are rejected.

Files: