Qt for HarmonyOS/qtohosextras doc/Window Drag Resize Example
Window Drag Resize Example
Demonstrates enabling drag-resize on sub windows and floating windows.
The main window creates either a sub window or a floating window; the floating variant is marked with QtOhosExtras::setShowWindowAsFloatWindowHint() before being shown. Each created window contains a toggle button that calls QtOhosExtras::setWindowDragResizable() with the checked state, enabling or disabling resize by dragging.
Marking a window as a floating window before showing it:
[window = &window]() {
auto *newWindow = createDragResizableWindow("Float window", window);
QtOhosExtras::setShowWindowAsFloatWindowHint(newWindow, true);
newWindow->show();
}));
Toggling the drag-resize setting:
auto updateDragResizable = [enableDragButton, windowToEnableDrag]() {
auto checked = enableDragButton->isChecked();
enableDragButton->setText(
checked
? QLatin1String("Reset window drag resizable")
: QLatin1String("Set window drag resizable"));
QtOhosExtras::setWindowDragResizable(windowToEnableDrag, checked);
};
Note: The functionality only applies to sub windows and floating windows; application main windows are not supported. The QWidget overload may be called before or after the window is shown.
Files: