QElidingLabel#
QLabel
variant that will elide text (i.e. add an ellipsis)
if it is too long to fit in the available space.
from qtpy.QtWidgets import QApplication
from superqt import QElidingLabel
app = QApplication([])
widget = QElidingLabel(
"a skj skjfskfj sdlf sdfl sdlfk jsdf sdlkf jdsf dslfksdl sdlfk sdf sdl "
"fjsdlf kjsdlfk laskdfsal as lsdfjdsl kfjdslf asfd dslkjfldskf sdlkfj"
)
widget.setWordWrap(True)
widget.resize(300, 20)
widget.show()
app.exec_()
Qt Class#
Methods#
A QLabel variant that will elide text (could add '…') to fit width.
QElidingLabel() QElidingLabel(parent: Optional[QWidget], f: Qt.WindowFlags = ...) QElidingLabel(text: str, parent: Optional[QWidget] = None, f: Qt.WindowFlags = ...)
For a multiline eliding label, use setWordWrap(True)
. In this case, text
will wrap to fit the width, and only the last line will be elided.
When wordWrap()
is True, sizeHint()
will return the size required to fit
the full text.