6

QGIS seems to have an integrated animation which purpose is to tell the user "Please wait, I am not freezing, I am processing"

loading bar in GUI QGIS loading bar

What is especially cool about it is that it is perfectly integrated to QGIS GUI (docked in the bottom) and doesn't fill itself like a QProgressBar : it just bounces from one side to another, giving no informations about the progression, just saying "Wait, I am processing".

I would like to know if it is possible to call this bar from a plugin.

I know of alternate options, which are displaying a QProgressBar (in my plugin gui or in a QMessageBar). I even found this post, which seemed to ask the same question I am asking but ended accepting "Display a standard QProgressBar in a QMessageBar" as an answer. And this isn't what I want.

I am not considering options on how to tell my user to wait. I would like to know if there is a way to call this specific bar.

7

Create bar:

bar = QProgressBar()

Set range from 0 to 0:

bar.setRange(0,0)

And now you have: enter image description here

Just set normal values like (0,100) if you want to end this "busy" state.

If you want to place this bar in that place, you have to add it to this object:

iface.mainWindow().statusBar().addWidget(bar)

Here is a documentation and you can find more informations about that: http://doc.qt.io/qt-4.8/qstatusbar.html

3
  • Thanks, that solves the most important part of my problem. This creates a bar that indicates "busy" state the way I want to. Still, I'd like to know if this bar could be docked the way the one QGIS uses is. (See the picture I added to my question to make it clearer) If I end up not finding how to do so, I'd accept your answer ! – El Theo Sep 12 '16 at 12:08
  • You can get access to this object with: iface.mainWindow().statusBar(). I'm going to edit my post with that. – dmh126 Sep 12 '16 at 12:48
  • 3
    Thanks a lot ! Quick note for anyone who would like to put the bar exactly where QGIS does (like in the picture in the question) : The syntax is : iface.mainWindow().statusBar().insertPermanentWidget(0, bar) (It can be found in the documentation dmh126 linked) – El Theo Sep 13 '16 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.