qt status bar center align?

ZolaKt picture ZolaKt · Dec 9, 2010 · Viewed 10.5k times · Source

How can I center align the text in QStatusBar? By default it is always left aligned.

I know I can add a QLabel and set alignment, but I want to use plain text, and .showMessage(QString, int) method, so I can add the timeout value.

Answer

OliJG picture OliJG · Dec 10, 2010

A QStatusBar has three functions of note here:

addPermanentWidget - Places a widget right aligned

addWidget - Places a widget left aligned which can be obscured by status messages

showMessage - Displays a status message

These are well established standards for status bars. While you could hack away to get what you're looking for, I'd suggest you reconsider your needs. Perhaps your QLabel should be placed with addPermanentWidget instead?

Take a look at the docs for more info: http://doc.qt.io/qt-5/qstatusbar.html