Progress
A rounded progress track with animated determinate updates and an indeterminate state.
Loading preview…
Live C++Source and licences
#include <QApplication>
#include <QFile>
#include <QHBoxLayout>
#include <QLabel>
#include <QPainter>
#include <QStandardItemModel>
#include <QUrl>
#include <QVBoxLayout>
#include <array>
#ifdef SHADCN_GALLERY_MEDIA
#include <shadcn/media.hpp>
#endif
#include <shadcn/shadcn.hpp>
QWidget* example(QWidget* parent = nullptr) {
using namespace shadcn;
auto* canvas = new QWidget(parent);
canvas->setAutoFillBackground(true);
auto* outer = new QHBoxLayout(canvas);
outer->setContentsMargins(32, 32, 32, 32);
auto* host = new QWidget(canvas);
auto* layout = new QVBoxLayout(host);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(16);
outer->addStretch();
outer->addWidget(host, 0, Qt::AlignCenter);
outer->addStretch();
auto* progress = new Progress(host);
progress->setAccessibleName("Download progress");
progress->setFixedWidth(320);
progress->setValue(60);
layout->addWidget(progress);
return canvas;
}
Installation
- Source
- Installed package
add_subdirectory(shadcn-cpp)
target_link_libraries(app PRIVATE shadcn::widgets)
find_package(shadcn CONFIG REQUIRED)
target_link_libraries(app PRIVATE shadcn::widgets)
Usage
#include <shadcn/widgets.hpp>
shadcn::Progress progress(parent);
progress.setRange(0, 100);
progress.setValue(39);
Set both range bounds to zero to show an indeterminate track.
progress.setRange(0, 0);
API
The public class keeps the QProgressBar range and value API. Determinate updates animate when full motion is enabled. Reduced motion updates the value without the transition.
Accessibility
Set a useful accessible name on the progress widget. Provide nearby text when the numeric value alone does not explain what is loading.