Sam
Sam

Reputation: 133

How to get a QProgressBar in QT with rounded edges and rounded progress edges?

I have created a vertical progress bar and an trying to style it with rounded edges. No matter what I do, I don't seem to be able to get the progress or chunk of the progress bar (QProgressBar::chunk) with rounded edges. Please help me out, I am new to QT.

Please find my code below:-

progressbar_V = new QProgressBar;
progressbar_V->setParent(this);
progressbar_V->setMinimum(0);
progressbar_V->setMaximum(5);
progressbar_V->setValue(3);
progressbar_V->setStyleSheet("QProgressBar{ border: solid grey; border-width: 6; border-radius: 12; color: black; text-align: centre; margin-right: 12; }, QProgressBar::chunk:vertical {background-color: #05B8CC; width: 20px;}");
progressbar_V->setGeometry(250,250,60,300);
progressbar_V->setOrientation(Qt::Vertical);

The Progress Bar text is at the top in the output as well. How will I get it to the middle of the vertical progress bar

Upvotes: 0

Views: 3634

Answers (2)

Kalitsune
Kalitsune

Reputation: 105

You're right, you can use this parameter:

border-radius: 50px;

to get round borders ! but you just forgotten to specify px at the end

So, once your code is updated, it looks like this :

progressbar_V->setStyleSheet("QProgressBar{ border: solid grey; border-width: 6; border-radius: 12px; color: black; text-align: centre; margin-right: 12; }, QProgressBar::chunk:vertical {background-color: #05B8CC; width: 20px;}");

Upvotes: 0

Pande.K
Pande.K

Reputation: 11

You need to change your style sheet into something like this:

progressbar_V->setStyleSheet("QProgressBar{ border: solid grey;border-bottom-right-radius: 12px;border-bottom-left-radius: 12px; color: black; text-align: centre; },QProgressBar::chunk {background-color: #05B8CC;border-bottom-right-radius: 7px;border-bottom-left-radius: 7px;}");

happy coding..

Upvotes: -1

Related Questions