How to fix height and width of filedailog in qml.
-
wrote on 15 May 2024, 10:18 last edited by
-
wrote on 19 Mar 2025, 06:58 last edited by
In Qt, QFileDialog is a native dialog by default on most platforms, meaning it uses the platform's file dialog and not Qt's own QFileDialog widget. Because of this, setting width, height, or applying a background overlay is often not possible when the native dialog is used.
However, you have two options to customize its size and background:
1: Use Non-Native QFileDialog
2: Custom Overlay Outside QFileDialog -
In Qt, QFileDialog is a native dialog by default on most platforms, meaning it uses the platform's file dialog and not Qt's own QFileDialog widget. Because of this, setting width, height, or applying a background overlay is often not possible when the native dialog is used.
However, you have two options to customize its size and background:
1: Use Non-Native QFileDialog
2: Custom Overlay Outside QFileDialogwrote on 19 Mar 2025, 08:36 last edited by@SuhasKrishanamurthy
The OP is posting in a QML forum and asking about QML'sFileDialog
. Your response is about Qt widget'sQFileDialog
, having features like ability to select to use non-native vs native dialog. Does this even apply to QML'sFileDialog
? I don't use QML, but maybe not. OP's screenshot looks to me like native file dialog under Ubuntu/GNOME, but not sure. -
wrote on 19 Mar 2025, 08:55 last edited by
You're right — my earlier response was focused on QFileDialog from Qt Widgets, but the OP is indeed asking about QML's FileDialog.
If the OP needs full control over the size or wants to add a background overlay, the alternative would be to create a custom file browser UI in QML using FolderListModel, ListView, and other controls instead of relying on FileDialog.Thanks again for pointing this out!