Basic input
FileDropZone
A file entry surface with drag feedback, keyboard access, and a separate browse action.
Example

Usage
Add to your workspace
Use setDescription() and setHintText() to describe accepted files. The example lists chosen files in a FileListView below.
#include <FluentQt/BasicInput.h>
using namespace fluent::basicinput;
auto* panel = new QWidget(this);
auto* layout = new QVBoxLayout(panel);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(24);
auto* drop = new FileDropZone(panel);
drop->setObjectName("fileDropZone");
drop->setDescription("Add documents, images or a ZIP archive.");
drop->setHintText("PDF, PNG, JPG, ZIP · Up to 20 MB per file");
layout->addWidget(drop);
auto* heading = new Label("Files", panel);
heading->setFluentTypography(Typography::FontRole::BodyStrong);
layout->addWidget(heading);
auto* model = new QStandardItemModel(panel);
auto addFile = [model](const QString& name, const QString& detail,
FileListView::Status state, qreal progress) {
auto* item = new QStandardItem(name);
item->setData(detail, FileListView::MetadataRole);
item->setData(state, FileListView::StatusRole);
item->setData(progress, FileListView::ProgressRole);
model->appendRow(item);
};
addFile("brand-guidelines.pdf", "2.4 MB · Ready to use", FileListView::Ready, 1.0);
addFile("product-shot.png", "3.6 / 5.8 MB · Uploading", FileListView::Uploading, 0.62);
addFile("archive.zip", "28 MB · Exceeds the 20 MB limit", FileListView::Rejected, 0.0);
auto* files = new FileListView(panel);
files->setObjectName("selectedFiles");
files->setAccessibleName("Selected files");
files->setBackgroundVisible(false);
files->setBorderVisible(false);
files->setProperty("fluentPreserveParentSurface", true);
files->viewport()->setProperty("fluentPreserveParentSurface", true);
files->setMinimumHeight(260);
files->setModel(model);
layout->addWidget(files);
QObject::connect(files, &FileListView::removeRequested, panel,
[model](const QModelIndex& index) { model->removeRow(index.row()); });
auto acceptFile = [drop, addFile](const QString& name, qint64 bytes) {
const QString suffix = QFileInfo(name).suffix().toLower();
const bool typeAllowed = QStringList{"pdf", "png", "jpg", "jpeg", "zip"}.contains(suffix);
const bool sizeAllowed = bytes <= 20 * 1024 * 1024;
if (!typeAllowed || !sizeAllowed) {
const QString reason = !typeAllowed ? "This file type is not supported."
: "Choose a file under 20 MB.";
drop->setErrorMessage(name + " · " + reason);
addFile(name, reason, FileListView::Rejected, 0.0);
return;
}
drop->clearError();
addFile(name, QString::number(bytes / (1024.0 * 1024.0), 'f', 1) + " MB · Ready to use",
FileListView::Ready, 1.0);
};
QObject::connect(drop, &FileDropZone::filesDropped, panel,
[acceptFile](const QList<QUrl>& urls) {
for (const QUrl& url : urls) {
const QFileInfo file(url.toLocalFile());
if (file.isFile())
acceptFile(file.fileName(), file.size());
}
});
QObject::connect(drop, &FileDropZone::browseRequested, panel, [panel, acceptFile]() {
platform::chooseFiles(panel, "Documents (*.pdf *.png *.jpg *.jpeg *.zip)", acceptFile);
});import fluentqt
from PySide6.QtCore import QFileInfo, Qt
from PySide6.QtGui import QStandardItem, QStandardItemModel
from PySide6.QtWidgets import QFileDialog, QVBoxLayout, QWidget
panel = QWidget()
layout = QVBoxLayout(panel)
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(24)
model = QStandardItemModel(panel)
roles = fluentqt.FileListView.DataRole
states = fluentqt.FileListView.Status
def add_file(name, detail, state, progress):
item = QStandardItem(name)
item.setData(detail, roles.MetadataRole)
item.setData(state, roles.StatusRole)
item.setData(progress, roles.ProgressRole)
model.appendRow(item)
add_file("brand-guidelines.pdf", "2.4 MB · Ready to use", states.Ready, 1.0)
add_file("product-shot.png", "3.6 / 5.8 MB · Uploading", states.Uploading, 0.62)
add_file("archive.zip", "28 MB · Exceeds the 20 MB limit", states.Rejected, 0.0)
drop = fluentqt.FileDropZone(panel)
drop.setObjectName("fileDropZone")
drop.setDescription("Add documents, images or a ZIP archive.")
drop.setHintText("PDF, PNG, JPG, ZIP · Up to 20 MB per file")
layout.addWidget(drop)
heading = fluentqt.Label("Files", panel)
heading.setFluentTypography(fluentqt.FontRole.BodyStrong)
layout.addWidget(heading)
files = fluentqt.FileListView(panel)
files.setObjectName("selectedFiles")
files.setAccessibleName("Selected files")
files.setBackgroundVisible(False)
files.setBorderVisible(False)
files.setProperty("fluentPreserveParentSurface", True)
files.viewport().setProperty("fluentPreserveParentSurface", True)
files.setMinimumHeight(260)
files.setModel(model)
layout.addWidget(files)
files.removeRequested.connect(lambda index: model.removeRow(index.row()))
def accept_file(path):
file = QFileInfo(path)
if not file.isFile():
return
type_allowed = file.suffix().lower() in ("pdf", "png", "jpg", "jpeg", "zip")
size_allowed = file.size() <= 20 * 1024 * 1024
if not type_allowed or not size_allowed:
reason = "Choose a file under 20 MB."
if not type_allowed:
reason = "This file type is not supported."
drop.setErrorMessage(file.fileName() + " · " + reason)
add_file(file.fileName(), reason, states.Rejected, 0.0)
return
drop.clearError()
detail = f"{file.size() / (1024 * 1024):.1f} MB · Ready to use"
add_file(file.fileName(), detail, states.Ready, 1.0)
def dropped(urls):
for url in urls:
accept_file(url.toLocalFile())
def browse():
dialog = QFileDialog(panel, "Choose files")
dialog.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
dialog.setFileMode(QFileDialog.FileMode.ExistingFiles)
dialog.setNameFilter("Documents (*.pdf *.png *.jpg *.jpeg *.zip)")
dialog.filesSelected.connect(
lambda paths: [accept_file(path) for path in paths]
)
dialog.open()
panel._file_dialog = dialog
drop.filesDropped.connect(dropped)
drop.browseRequested.connect(browse)API
DeclarationNo matching API members.
fluent::basicinput::FileDropZone
Inherits QWidget · FluentElement · QMLPlus
File entry surface with local-URL drop and application-owned browsing.
Constructors
Properties
QString title- Read
title()WritesetTitle()NotifytitleChanged() QString description- Read
description()WritesetDescription()NotifydescriptionChanged() QString hintTextOptional application-owned limits or format hint.
ReadhintText()WritesetHintText()NotifyhintTextChanged()QString browseText- Read
browseText()WritesetBrowseText()NotifybrowseTextChanged() QString errorMessageValidation feedback that replaces the description until cleared.
ReaderrorMessage()WritesetErrorMessage()NotifyerrorMessageChanged()bool dragActive- Read
isDragActive()NotifydragActiveChanged()
Methods
QString hintText() constOptional application-owned limits or format hint.
void setHintText(const QString& text)Optional application-owned limits or format hint.
QString errorMessage() constValidation feedback that replaces the description until cleared.
void setErrorMessage(const QString& message)Validation feedback that replaces the description until cleared.
Signals
void hintTextChanged(const QString& text)Optional application-owned limits or format hint.
void errorMessageChanged(const QString& message)Validation feedback that replaces the description until cleared.
void browseRequested()Requests an application-provided file picker.
void filesDropped(const QList<QUrl>& urls)Delivers local URLs in their original order after an accepted copy drop.
Subclass interfaces
Methods
Inherited from fluent::FluentElement
Methods
static void setTheme(Theme theme)Updates the global theme and notifies active FluentElement instances.
static void setThemeDeferred(Theme theme)Schedules a visible-first batched theme refresh without blocking the current interaction.
static Theme currentTheme()Returns the currently active global theme.
static bool themeUsesDarkAppearance(Theme theme)Returns whether a theme uses dark-backed chrome and material tokens.
static void refreshTheme()Re-broadcasts the current theme to repaint after a design-token change.
static int themeGeneration()Monotonic counter bumped on every theme change, for staleness checks.
Theme effectiveTheme() constResolves the theme used by this element, honoring an inherited QWidget override.
bool effectiveThemeUsesDarkAppearance() constReturns whether this element's effective theme uses dark-backed chrome.
bool setThemeOverrides(const QJsonObject& overrides)Component-facing token accessors.
QJsonObject themeOverrides() constReturns this element's authored overrides.
void clearThemeOverrides()Restores all token fields to global theme defaults.
const Colors& themeColorsRef() constNon-copying access to the active color set (for hot paint paths).
Material::AcrylicToken themeAcrylic() constMaterial, elevation, and adaptive layout tokens.
QColor themeBackdrop(bool active) constWindow-chrome backdrop color for the given activation state.
virtual void onThemeUpdated()Called after the global theme changes.
Enumerations
enum ThemeGlobal visual theme used when resolving design tokens.
Light = 0Dark = 1HighContrast = 2
Types and aliases
struct ColorsDesign token snapshots returned to components.
Inherited from fluent::QMLPlus
Methods
AnchorLayout::Anchors* anchors()Returns mutable anchors for the QWidget host.
void setState(const QString& name)Applies a named state, or clears state when name is empty.
void addState(const QMLState& state)Registers or replaces a named state definition.
void evaluateStates()Reevaluates conditions; the first registered true condition wins.
QMLPlusRuntime* runtime()Returns the lazy host-owned state observation object.
void setAnchors(const AnchorLayout::Anchors& anchors)Replaces all host anchors and invalidates the parent layout.
void resetAnchors()Clears all host anchors and invalidates the parent layout.
void bind(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction dir = PropertyBinder::OneWay)Binds a source property to a property on the QWidget host.
BindingHandle bindManaged(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction direction = PropertyBinder::OneWay, BindingOptions options = {})Installs a managed direct binding on this QWidget host.
BindingHandle bindComputed(const char* targetProp, const QVector<BindingDependency>& dependencies, std::function<QVariant()> evaluate, BindingOptions options = {})Installs an explicit-dependency C++ expression on this QWidget host.
void addTransition(const StateTransition& transition)Registers a state transition in precedence order.
void setBehavior(const char* propertyName, const PropertyAnimation& animation)Sets the default animation for this host's managed property writes.
void clearBehavior(const char* propertyName)Removes the default animation for future managed writes.
bool writeProperty(const char* propertyName, const QVariant& value)Writes a host property through Behavior without removing its binding.
All inherited Qt members:QWidget