How to show the long text on a label that just show the latest part.
-
e.g. a label's width is 100 (pixel) ,a text's width is 200 (pixel), i want the label just show last 100 pixel content of the text, the label's size policy is fixed. Now it just shows the first 100 pixel and also without ellipsis to remind it has other 100 pixel. So how to do that ,thank you.
-
e.g. a label's width is 100 (pixel) ,a text's width is 200 (pixel), i want the label just show last 100 pixel content of the text, the label's size policy is fixed. Now it just shows the first 100 pixel and also without ellipsis to remind it has other 100 pixel. So how to do that ,thank you.
hi @Mihan
take a look at this elided label example:
https://doc.qt.io/qt-5/qtwidgets-widgets-elidedlabel-example.html
-
not something I've ever had to do so there is probably a better way...but, I would most likely write the text to a bitmap, clip the bitmap to the relevant window, and then display it in the widget.
-
not something I've ever had to do so there is probably a better way...but, I would most likely write the text to a bitmap, clip the bitmap to the relevant window, and then display it in the widget.
@Kent-Dorfman also I have an idea that use
drawText()
on a widget like you said, but i think it is cumbersome XD. So I want to get a better way to do that~ -
@Kent-Dorfman also I have an idea that use
drawText()
on a widget like you said, but i think it is cumbersome XD. So I want to get a better way to do that~@Mihan
I wouldn't be too concerned...unless you're in a really resource constrained system. -
@Mihan
I wouldn't be too concerned...unless you're in a really resource constrained system.@Kent-Dorfman Yep, running on ARM. BTW, could you tell me how to make a LineEdit's text cursor always is visible. I found something in source code ,
if (QApplication::keypadNavigationEnabled()) { if (e->type() == QEvent::EnterEditFocus) { end(false); d->setCursorVisible(true); d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); } else if (e->type() == QEvent::LeaveEditFocus) { d->setCursorVisible(false); d->control->setCursorBlinkPeriod(0); if (d->control->hasAcceptableInput() || d->control->fixup()) emit editingFinished(); } }
it's in QLineEdit's
event()
, so how can I use thissetCursorVisible(bool)
? -
@Kent-Dorfman Yep, running on ARM. BTW, could you tell me how to make a LineEdit's text cursor always is visible. I found something in source code ,
if (QApplication::keypadNavigationEnabled()) { if (e->type() == QEvent::EnterEditFocus) { end(false); d->setCursorVisible(true); d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); } else if (e->type() == QEvent::LeaveEditFocus) { d->setCursorVisible(false); d->control->setCursorBlinkPeriod(0); if (d->control->hasAcceptableInput() || d->control->fixup()) emit editingFinished(); } }
it's in QLineEdit's
event()
, so how can I use thissetCursorVisible(bool)
?