Есть у QLabel есть одна особенность. Её минимальный размер определяется текстом, который в неё записан. Это приводит к тому что длинный текст принудительно увеличивает ширину интерфейса.
В большинстве случаев это выглядит плохо.
Как с этим бороться?
🔸 Обрезать текст заранее, задав лимит по длине строки. В этом случае мы теряем часть визуальной информации. Не всегда угадаешь нужный размер. В разных OS шрифт используется разный.
🔸 Делать перенос строки. Тогда мы получим изменение размера в другую сторону, что тоже поломает интерфейс.
🔸 Переопределить paintEvent() и сделать кастомный рендеринг текста. Можно, но слишком сложно для такой задачи.
Проще всего обрезать текст под текущий размер виджета используя класс QFontMetrics.
Он имеет готовый метод elidedText(), который просто вызываем по событию resizeEvent.
Я также добавил установку ToolTip чтобы всегда можно было увидеть полный текст при наведении курсора.
🌎 Код здесь
#qt#source
🪙SPIN & GET REAL CRYPTO
A new feature is live: Giveaways by MemeFi!💥
😵 Prize pool starts at $1,000,000!
How to win?
⭐️Spin the wheel
🔷 Hit the Ether icons
💯 Fill the Ether bar for a ticket to win $ETH!
The event kicks off today with a $25,000 prize pool. Each day brings new giveaways! 🥇
🔔Subscribe👉Join MemeFi
⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️
#memefi#spin#crypto
📣 Catizens! We are about to welcome the next update, includes:
Still worried about not being able to automatically buy the highest-grade airdrop cats? 📦
· The auto-buy function is coming soon! #Free your hands! 🚀
· At the same time, the offline #rewards have also been greatly advanced! This will make it easier for players to level up their cats, make #Catizen a real idle casual game! 😻
· Catizen has also adjusted the play experience of #SPIN(Increased randomness and reduced difficulty), don’t forget to try it again!
https:://t.me/catizenbot/👈
#crypto#ton#game
Spin (verb)/(noun)
Verb: to present information in a favorable or strategic way
Noun: a biased or strategic way of presenting information
Example (verb):
The government tried to spin the economic data as a success.
دولت تلاش کرد دادههای اقتصادی را بهگونهای ارائه کند که موفقیتآمیز به نظر برسد.
Example (noun):
The press secretary put a positive spin on the policy failure.
سخنگوی مطبوعاتی به شکست سیاست، تفسیر مثبتی داد.
Put a spin on : present something strategically
She put a positive spin on the election results.
او نتایج انتخابات را به شکل مثبتی تفسیر کرد.
Spin doctor : political advisor who manages public perception
The spin doctor tried to downplay the scandal.
مشاور سیاسی سعی کرد رسوایی را کماهمیت جلوه دهد.
#idioms
#discourseanalysis
#criticalthinking
#spin
#framing
#ielts#cae#fce