December 12, 2010

goocreations goocreations
Ant Farmer
157 posts

QProgressBar Chunk

 

I’ve tried google for this, but I’m not sure what to search for.

I’m looking for a way to change a QProgressBar so that only a chunk with a fixed size is moving. That is, the progress bar is not filling up from one side to another, but that only a chunk/part is moving from one side to another. (If the progress bar is 100px, I only want a 10px chunk moving from left to right).

I think I saw something like this in KDE.

9 replies

December 12, 2010

Gerolf Gerolf
Area 51 Engineer
3210 posts

Hi,

look at the class documentation: QProgressBar [doc.qt.nokia.com]
It’s a bit tricky, but set minimum = 0, maximum=0, value=-1.On windows, that works …

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

December 12, 2010

goocreations goocreations
Ant Farmer
157 posts

Wow, thats cool. Is there anyway to change the size of the chunk or the speed of movement?

December 12, 2010

Andre Andre
Area 51 Engineer
6031 posts

Only in the style, I think.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

December 12, 2010

Gerolf Gerolf
Area 51 Engineer
3210 posts

Could be that it only works on windows with windows style. And I think, if you use style sheets, it does not work anymore, especially in 4.5, there we triesd that with a style sheet. Whether that is fixed in 4.7 I don’t know…

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

December 12, 2010

Gerolf Gerolf
Area 51 Engineer
3210 posts

I tried it with differen styles (modife, CDE, plastique, cleanlooks, windows, windows XP, windows vista) and it worked in all.
And I tried to style it, it is also possible:

  1.  QProgressBar::chunk {
  2.      background-color: #05B8CC;
  3.      width: 20px;
  4.  }

used as style sheet. See Styling the progress bar [doc.qt.nokia.com]

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

December 12, 2010

goocreations goocreations
Ant Farmer
157 posts

Thank you very much for your help

December 12, 2010

Mattias Cibien Mattias Cibien
Lab Rat
66 posts

Looks like there is not a way to make the QProgressBar in maquee style (I think it what goocreations mean).

Marquee

Is it the second bar you’d like to use?

 Signature 

http://mattias-cibien.co.cc
- Prepare for Qt consequences.

December 12, 2010

goocreations goocreations
Ant Farmer
157 posts

Yip, exactly that bar is what I need (2nd one)

December 12, 2010

Mattias Cibien Mattias Cibien
Lab Rat
66 posts

It is a marquee bar.

From Qt Documentarion:

If minimum and maximum both are set to 0, the bar shows a busy indicator instead of a percentage of steps. This is useful, for example, when using QFtp or QNetworkAccessManager to download items when they are unable to determine the size of the item being downloaded.

Tested and working

 Signature 

http://mattias-cibien.co.cc
- Prepare for Qt consequences.

 
  ‹‹ Exception Handling, Throwing Exception and Try/Catch blocks      Qt + QGLWidget Debug problem ››

You must log in to post a reply. Not a member yet? Register here!