Есть у QLabel есть одна особенность. Её минимальный размер определяется текстом, который в неё записан. Это приводит к тому что длинный текст принудительно увеличивает ширину интерфейса.
В большинстве случаев это выглядит плохо.
Как с этим бороться?
🔸 Обрезать текст заранее, задав лимит по длине строки. В этом случае мы теряем часть визуальной информации. Не всегда угадаешь нужный размер. В разных OS шрифт используется разный.
🔸 Делать перенос строки. Тогда мы получим изменение размера в другую сторону, что тоже поломает интерфейс.
🔸 Переопределить paintEvent() и сделать кастомный рендеринг текста. Можно, но слишком сложно для такой задачи.
Проще всего обрезать текст под текущий размер виджета используя класс QFontMetrics.
Он имеет готовый метод elidedText(), который просто вызываем по событию resizeEvent.
Я также добавил установку ToolTip чтобы всегда можно было увидеть полный текст при наведении курсора.
🌎 Код здесь
#qt#source
News: #Tulu Kappi gold mine officially launched in West #Wollega Zone
The gold development project at Tulu Kappi, located in Ganji district of West Wollega, has officially begun operations. On 18 February 2026, Prime Minister Abiy Ahmed, alongside Oromia Regional President Shimallis Abdisa, government officials, and project leaders, inaugurated the construction and development work of the site.
The project site lies 28 km east of Ayra town and covers approximately eight square kilometers. The project is led by KEFI Minerals, which acquired the site in 2014 from Nyota Minerals, previously engaged in exploration activities.
Prior to the official launch, KEFI held consultations with local communities and government officials to agree on resettlement plans and work arrangements.
https://addisstandard.com/?p=55257
Enat Party Alleges Government Forces Massacring Civilians In East Wollega. Read more. https://borkena.com/2025/12/12/enat-party-alleges-government-forces-massacring-civilians-in-east-wollega/#Ethiopia#humanrights#wollega#EnatParty
Reported Drone Strike in Wollega, Oromia region of Ethiopia. Read more.
https://borkena.com/2026/04/17/ethiopia-reported-drone-strike-in-wollega-oromia-region/#Ethiopia#News#Wollega#Dronestrike#humanrights
#GPE_EarlyWarning
April 24, 2026
Urgent Information: #Wollega‼️
Specific areas: #EastWollega Zone, #AngerGutin town
It has been five days since five district (woreda) leaders from areas in the East Wollega Zone with significant Amhara populations began a closed-door meeting in Anger Gutin town, alongside high-ranking officials from the regional level.
Our sources have confirmed that an agreement has been reached to launch a large-scale attack against the Amhara people. Therefore, we urge the entire population to take all necessary precautions and preparations.
___________________
For more updates follow us on:
➡️ Facebook: https://facebook.com/gpethiopia
➡️ X: https://X.com/gpethiopia
➡️ Instagram: https://instagram.com/gpethiopia
➡️ TikTok: https://www.tiktok.com/@gpethiopia
➡️ Telegram: https://t.me/gpe_central
➡️ WhatsAPP: https://whatsapp.com/channel/0029VaAazxGBFLgaX9umXK2M
➡️ Medium: https://gpethiopia.medium.com/