fix: layout issue (progress bar not horizontally centralized) in qt6.4.5

This commit is contained in:
2026-01-15 05:27:57 +01:00
parent d7843bc37e
commit c952ce17e2
4 changed files with 12 additions and 14 deletions
+1 -7
View File
@@ -11,14 +11,8 @@
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="0"> <item row="1" column="0" alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QProgressBar" name="progressBar"> <widget class="QProgressBar" name="progressBar">
<property name="maximumSize">
<size>
<width>500</width>
<height>16777215</height>
</size>
</property>
<property name="value"> <property name="value">
<number>24</number> <number>24</number>
</property> </property>
+5 -3
View File
@@ -1,14 +1,16 @@
/* /*
* @Author: Uyanide pywang0608@foxmail.com * @Author: Uyanide pywang0608@foxmail.com
* @Date: 2025-08-07 00:32:25 * @Date: 2025-08-07 00:32:25
* @LastEditTime: 2025-08-07 21:14:09 * @LastEditTime: 2026-01-15 05:23:55
* @Description: LoadingIndicator implementation. * @Description: LoadingIndicator implementation.
*/ */
#include "loading_indicator.h" #include "loading_indicator.h"
LoadingIndicator::LoadingIndicator(QWidget* parent) : QWidget(parent), LoadingIndicator::LoadingIndicator(int barMinimumWidth, QWidget* parent)
ui(new Ui::LoadingIndicator) { : QWidget(parent),
ui(new Ui::LoadingIndicator) {
ui->setupUi(this); ui->setupUi(this);
ui->progressBar->setMinimumWidth(barMinimumWidth);
} }
LoadingIndicator::~LoadingIndicator() { LoadingIndicator::~LoadingIndicator() {
+2 -2
View File
@@ -1,7 +1,7 @@
/* /*
* @Author: Uyanide pywang0608@foxmail.com * @Author: Uyanide pywang0608@foxmail.com
* @Date: 2025-08-07 00:32:25 * @Date: 2025-08-07 00:32:25
* @LastEditTime: 2025-08-07 21:13:59 * @LastEditTime: 2026-01-15 05:24:14
* @Description: A loading indicator widget with a progress bar. * @Description: A loading indicator widget with a progress bar.
*/ */
#ifndef LOADING_INDICATOR_H #ifndef LOADING_INDICATOR_H
@@ -19,7 +19,7 @@ class LoadingIndicator : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit LoadingIndicator(QWidget* parent = nullptr); explicit LoadingIndicator(int barMinimumWidth = 500, QWidget* parent = nullptr);
~LoadingIndicator(); ~LoadingIndicator();
void setMaximum(int max) { ui->progressBar->setMaximum(max); } void setMaximum(int max) { ui->progressBar->setMaximum(max); }
+4 -2
View File
@@ -1,7 +1,7 @@
/* /*
* @Author: Uyanide pywang0608@foxmail.com * @Author: Uyanide pywang0608@foxmail.com
* @Date: 2025-08-05 00:37:58 * @Date: 2025-08-05 00:37:58
* @LastEditTime: 2026-01-15 02:01:19 * @LastEditTime: 2026-01-15 05:26:49
* @Description: MainWindow implementation. * @Description: MainWindow implementation.
*/ */
#include "main_window.h" #include "main_window.h"
@@ -10,6 +10,7 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QProcess> #include <QProcess>
#include <QPushButton> #include <QPushButton>
#include <algorithm>
#include <functional> #include <functional>
#include "./ui_main_window.h" #include "./ui_main_window.h"
@@ -50,7 +51,8 @@ void MainWindow::_setupUI() {
m_carouselIndex = ui->stackedWidget->addWidget(m_carousel); m_carouselIndex = ui->stackedWidget->addWidget(m_carousel);
// create loading indicator // create loading indicator
m_loadingIndicator = new LoadingIndicator(this); int barWidth = m_config.getStyleConfig().windowWidth * 0.7;
m_loadingIndicator = new LoadingIndicator(barWidth, this);
connect(m_carousel, connect(m_carousel,
&ImagesCarousel::loadingStarted, &ImagesCarousel::loadingStarted,
this, this,