Есть у QLabel есть одна особенность. Её минимальный размер определяется текстом, который в неё записан. Это приводит к тому что длинный текст принудительно увеличивает ширину интерфейса.
В большинстве случаев это выглядит плохо.
Как с этим бороться?
🔸 Обрезать текст заранее, задав лимит по длине строки. В этом случае мы теряем часть визуальной информации. Не всегда угадаешь нужный размер. В разных OS шрифт используется разный.
🔸 Делать перенос строки. Тогда мы получим изменение размера в другую сторону, что тоже поломает интерфейс.
🔸 Переопределить paintEvent() и сделать кастомный рендеринг текста. Можно, но слишком сложно для такой задачи.
Проще всего обрезать текст под текущий размер виджета используя класс QFontMetrics.
Он имеет готовый метод elidedText(), который просто вызываем по событию resizeEvent.
Я также добавил установку ToolTip чтобы всегда можно было увидеть полный текст при наведении курсора.
🌎 Код здесь
#qt#source
🤖 Bot Downtime Update 🔧
Hey everyone,
Our bot is currently down due to a server-side issue from our hosting provider. This outage is not caused by us directly, but we’re in constant contact with the provider to ensure it gets resolved as quickly as possible.
We truly understand how frustrating this is — we’re equally affected and doing everything we can behind the scenes to bring the service back online.
🙏 Thanks for your patience and support.
We’ll keep you updated here. Please stay tuned.
#fixed✈️
Fixed an issue where @ChatNetworkBot in some cases didn't reply when it should send an invite link after the /start via deeplinking.
Thanks in helping diagnose, L.s. and C.
#fixed#ChatNetworkBot
🎈Hot Game This Week🎈
#Minecraft 1.21.92 LIVE!!
What's New?
🌟1.21.90 bugs #fixed!
Resolved a problem where adding split-screen players could disconnect users from multiplayer worlds.
🌟Visual Arts Adjusments!
Items with dimensions smaller than 16 pixels in width or height now display correctly once more.
🔗Minecraft 1.21.92 APK Patch Update
It was brought to attention that with some bots admin commands were no longer working.
That was happining for the bots migrated yesterday, because of the new bot API version.
This is #fixed now.
Thanks for letting me know, A. A.!
#BanWarnBot#RulesRulesBot#JoinCaptchaBot