#include int main(int argc, char *argv[]) { QApplication app(argc, argv); auto createProgressBar = [](int val, Qt::Orientation orientation, bool inverted) { auto pb = new QProgressBar; pb->setMaximum(100); pb->setValue(val); pb->setOrientation(orientation); pb->setInvertedAppearance(inverted); return pb; }; auto getLayout = [](QWidget *w, Qt::Orientation orientation) -> QBoxLayout * { if (orientation == Qt::Horizontal) return new QVBoxLayout(w); return new QHBoxLayout(w); }; auto createWidget = [&](Qt::Orientation orientation, bool inverted, const char *title) { QWidget *w = new QWidget; w->setWindowTitle(title); auto lay = getLayout(w, orientation); for (int i : {0, 1, 48, 52, 99, 100}) lay->addWidget(createProgressBar(i, orientation, inverted)); w->show(); }; createWidget(Qt::Horizontal, false, "Horizontal, normal"); createWidget(Qt::Vertical, false, "Vertical, normal"); createWidget(Qt::Horizontal, true, "Horizontal, inverted"); createWidget(Qt::Vertical, true, "Vertical, inverted"); return app.exec(); }