Re: Alignment Issue in QStatusbar

Tong Zhang <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <CABUYRu6ej1Qkb6V4dNjxZeg6L6SBNqCV+FbNJsN0xeR=SJd_jw@mail.gmail.com>
Thanks, Maurizio. I'm running with Linux, everything is fine now, what I
was missing is Qt.AlignVCenter, after I changing to
lbl.setAlignment(Qt.AlignLeft
| Qt.AlignVCenter), it looks perfect.
Here is the functional minimal testing script:
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QToolButton
from PyQt5.QtWidgets import QStatusBar
from PyQt5.QtWidgets import QLabel
from PyQt5.QtCore import Qt


class MyWindow(QMainWindow):
    def __init__(self, parent=None, **kws):
        QMainWindow.__init__(self, parent)
        self.setParent(parent)

        sb = QStatusBar(self)
        lbl = QLabel("My App (Version: 1.0)")
        lbl.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        btn = QToolButton(self)
        sb.addPermanentWidget(btn, 0)
        sb.addPermanentWidget(lbl, 1)

        self.setStatusBar(sb)


if __name__ == "__main__":
    from PyQt5.QtWidgets import QApplication
    import sys

    app = QApplication(sys.argv)
    m = MyWindow()
    m.show()

    sys.exit(app.exec_())

- Tong

On Fri, May 17, 2019 at 5:20 PM Maurizio Berti <[email protected]>
wrote:

> Il giorno ven 17 mag 2019 alle ore 04:25 Tong Zhang <
> [email protected]> ha scritto:
>
>> Hello,
>>
>> I'm trying to create add widgets into QStatusbar, as the attached
>> screenshot shows, the first widget, which is a qtoolbutton and the second
>> widget, which is a qlabel, is not aligned well. I want them vertically
>> center aligned,  could somebody give me some hint? Thanks very much!
>>
>
> From your code everything seems fine, but you should provide a minimal,
> correct and reproducible example to better understand what might be going
> on (my experience shows that what usually happens is that, once you
> "reduce" the code for the example, you often find what actually is wrong by
> yourself); it's also better to specify the environment you are running from
> (Operating System, Python and Qt versions).
>
> I tested it on Linux and Windows (through wine, though). From the look of
> the attached screenshot it seems you might be running on Windows 10, and
> unfortunately I cannot accurately test on that platform.
>
> It could be a bug, but also it might depend on what you did with the
> QStatusBar and the QToolButton (I can see an icon and a menu set, but maybe
> you changed something else too).
>
> Cheers,
> Maurizio
>
> --
> È difficile avere una convinzione precisa quando si parla delle ragioni
> del cuore. - "Sostiene Pereira", Antonio Tabucchi
> http://www.jidesk.net
>

_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.