Есть у QLabel есть одна особенность. Её минимальный размер определяется текстом, который в неё записан. Это приводит к тому что длинный текст принудительно увеличивает ширину интерфейса.
В большинстве случаев это выглядит плохо.
Как с этим бороться?
🔸 Обрезать текст заранее, задав лимит по длине строки. В этом случае мы теряем часть визуальной информации. Не всегда угадаешь нужный размер. В разных OS шрифт используется разный.
🔸 Делать перенос строки. Тогда мы получим изменение размера в другую сторону, что тоже поломает интерфейс.
🔸 Переопределить paintEvent() и сделать кастомный рендеринг текста. Можно, но слишком сложно для такой задачи.
Проще всего обрезать текст под текущий размер виджета используя класс QFontMetrics.
Он имеет готовый метод elidedText(), который просто вызываем по событию resizeEvent.
Я также добавил установку ToolTip чтобы всегда можно было увидеть полный текст при наведении курсора.
🌎 Код здесь
#qt#source
Ethiopia’s First R21 Malaria Vaccine Rollout, A Global First In A Refugee Camp (MSF)
https://borkena.com/2025/12/15/ethiopias-first-r21-malaria-vaccine-rollout-a-global-first-in-a-refugee-camp/#Ethiopia#Malaria#MSF
Eliminating #malaria requires continued implementation of measures proven to stop the local spread of the malaria parasite.
Every Nigerian has a role to play in accelerating the fight against #malaria infection⬇️
➡️Use insecticide-treated nets when sleeping in places where malaria is present
➡️Use mosquito repellents after dusk
➡️Use coils and vaporizers
➡️Wear protective clothing
➡️Use window nets
➡️Clear stagnant water in your environment to prevent the breeding of mosquitoes
#WorldMalariaDay2024
The theme for #WorldWaterDay2023 is 'Accelerating the change to solve the water and sanitation crisis'
Diseases like #cholera, #yellowfever, #typhoid and #malaria can be prevented by proper water/sewage management & by consumption of clean water
Be the change you want to see!
Mosquitoes are carriers of various diseases, including #Malaria, #YellowFever, #DengueFever, and #ZikaVirus, with cases rising during the rainy season.
You can protect yourself:
➡Eliminate stagnant water to prevent mosquito breeding
➡Use mosquito repellent and wear clothing that covers your arms and legs
➡Sleep under insecticide-treated mosquito nets
➡Keep drainages and gutters clear
➡Install screens on doors and windows
#WorldMosquitoDay