Есть у QLabel есть одна особенность. Её минимальный размер определяется текстом, который в неё записан. Это приводит к тому что длинный текст принудительно увеличивает ширину интерфейса.
В большинстве случаев это выглядит плохо.
Как с этим бороться?
🔸 Обрезать текст заранее, задав лимит по длине строки. В этом случае мы теряем часть визуальной информации. Не всегда угадаешь нужный размер. В разных OS шрифт используется разный.
🔸 Делать перенос строки. Тогда мы получим изменение размера в другую сторону, что тоже поломает интерфейс.
🔸 Переопределить paintEvent() и сделать кастомный рендеринг текста. Можно, но слишком сложно для такой задачи.
Проще всего обрезать текст под текущий размер виджета используя класс QFontMetrics.
Он имеет готовый метод elidedText(), который просто вызываем по событию resizeEvent.
Я также добавил установку ToolTip чтобы всегда можно было увидеть полный текст при наведении курсора.
🌎 Код здесь
#qt#source
😄Consider
➖➖➖➖➖➖
🔘 The verb, consider can mean spend time to think, or think about something
🔜 I'm going to take some time to consider, then I'll tell you my decision.
🔜I'm considering how we can best use our time.
🔘 Consider can have a similar meaning to 'take into account' to say that somethng is important when making a decision or judgement.
🔜 She's learnt so much, considering how late she started the course.
🔘 Consider can be used with an object and an adjective or noun to describe what we think something or someone is like.
🔜 I consider him to be the best writer of his generation.
🔜 I consider her an expert. She knows so much about history.
#Consider👨🏫@America
➖➖➖➖➖➖➖➖➖➖➖➖
🆕 Crypto News @Money
😁 Crypto Game @Egame
🇺🇸 US News @America
🇯🇵 Japan News @Japan
🇦🇪 UAE News @Dubai
▶️ Popular Movies @Videos
😜 Best Funny Video @Funnys
😄Consider
➖➖➖➖➖➖
🔘 The verb, consider can mean spend time to think, or think about something
🔜 I'm going to take some time to consider, then I'll tell you my decision.
🔜I'm considering how we can best use our time.
🔘 Consider can have a similar meaning to 'take into account' to say that somethng is important when making a decision or judgement.
🔜 She's learnt so much, considering how late she started the course.
🔘 Consider can be used with an object and an adjective or noun to describe what we think something or someone is like.
🔜 I consider him to be the best writer of his generation.
🔜 I consider her an expert. She knows so much about history.
#Consider👨🏫@America
➖➖➖➖➖➖➖➖➖➖➖➖
🆕 Crypto News @Money
😁 Crypto Game @Egame
🇺🇸 US News @America
🇯🇵 Japan News @Japan
🇦🇪 UAE News @Dubai
▶️ Popular Movies @Videos
😜 Best Funny Video @Funnys
😄Consider
➖➖➖➖➖➖
🔘 The verb, consider can mean spend time to think, or think about something
🔜 I'm going to take some time to consider, then I'll tell you my decision.
🔜I'm considering how we can best use our time.
🔘 Consider can have a similar meaning to 'take into account' to say that somethng is important when making a decision or judgement.
🔜 She's learnt so much, considering how late she started the course.
🔘 Consider can be used with an object and an adjective or noun to describe what we think something or someone is like.
🔜 I consider him to be the best writer of his generation.
🔜 I consider her an expert. She knows so much about history.
#Consider👨🏫@America
➖➖➖➖➖➖➖➖➖➖➖➖
🆕 Crypto News @Money
😁 Crypto Game @Egame
🇺🇸 US News @America
🇯🇵 Japan News @Japan
🇦🇪 UAE News @Dubai
▶️ Popular Movies @Videos
😜 Best Funny Video @Funnys
📰Colorado Lawmakers Consider Bill Allowing Older Adults to Opt Out of Jury Duty in State Courts
🔗https://dailycoloradonews.com/colorado-lawmakers-consider-bill-older-adults-opt-out-jury-duty/?utm_source=telegram&utm_medium=social&utm_campaign=zimm-distribute
via Daily Political Press
#Courts#Colorado#Lawmakers#Consider#Latest
📰Colorado Lawmakers Consider Bill Allowing Older Adults to Opt Out of Jury Duty in State Courts
🔗https://dailycoloradonews.com/colorado-lawmakers-consider-bill-older-adults-opt-out-jury-duty/?utm_source=telegram&utm_medium=social&utm_campaign=zimm-distribute
via Daily Political Press
#Courts#Colorado#Lawmakers#Consider#Latest