Есть у QLabel есть одна особенность. Её минимальный размер определяется текстом, который в неё записан. Это приводит к тому что длинный текст принудительно увеличивает ширину интерфейса.
В большинстве случаев это выглядит плохо.
Как с этим бороться?
🔸 Обрезать текст заранее, задав лимит по длине строки. В этом случае мы теряем часть визуальной информации. Не всегда угадаешь нужный размер. В разных OS шрифт используется разный.
🔸 Делать перенос строки. Тогда мы получим изменение размера в другую сторону, что тоже поломает интерфейс.
🔸 Переопределить paintEvent() и сделать кастомный рендеринг текста. Можно, но слишком сложно для такой задачи.
Проще всего обрезать текст под текущий размер виджета используя класс QFontMetrics.
Он имеет готовый метод elidedText(), который просто вызываем по событию resizeEvent.
Я также добавил установку ToolTip чтобы всегда можно было увидеть полный текст при наведении курсора.
🌎 Код здесь
#qt#source
🌸Beta Test Closing Announcement🌸
The Mystic Garden Beta Test has officially ended!
💎 Thank you to all the players who participated and helped shape the game. 🌱
🏆Winners List and rewards will be announced soon. Stay tuned for updates! 🚀
#MysticGarden#BetaTest#Web3Gaming
🚨 Mystic Garden Beta Test Reward Alert! 🚨
🌿 Dive into the enchanting world of Mystic Garden and claim your share of $500 AURA in rewards! 🌟
🎮 Beta Testers Wanted
💎 Exclusive prizes await 🌌
⏳ Don't miss the magic—beta testing opens soon!
#MysticGarden#BetaTest#Rewards
🌟How to Earn Crystals and Share $500 AURA in Mystic Garden?🌟
Beta Testers, this is your moment to shine! 🚀
🔹How to Share $500 AURA
• Harvest Crystals and sell them to earn GOLD.
• Rewards depend on the percentage of GOLD you contribute to the total GOLD from all players. 🏆
🔹Crystal Breakdown:
👉Tier 1 Elements🌱💧🔥🌬
• Earth, Water, Fire, Air
⏳ Growth Time: 1h - 1.5h
💎 Yield: 5-11 Crystals
🎁 Bonus Drop: 15-20% chance
👉Tier 2 Elements🪨⚙️🏖⚡️
• Combine Tier 1 to unlock:
Mud, Sand, Metal, Steam, Mist, Lightning
⏳ Growth Time: 2.5h - 8h
💎 Yield: 7-11 Crystals
👉Tier 3 Elements Coming Soon🌌
• Unlock combos like Light ☀️, Dark 🌑, Twilight!
🔔Leaderboard Mechanics:
• GOLD from selling Crystals determines your rank.
• Rewards are based on your GOLD percentage compared to all players. 🏅
Note: The parameters are not fixed, they will still be adjusted to always ensure suitability for the game!
The garden awaits. Grow and compete! 🌸
#MysticGarden#BetaTest#EarnRewards#CrystalLeaderboard
🎉 Our partner @chickizenTON is opening the Closed Beta Test phase to celebrate our partnership!
- Timeline: Now - 17:00 UTC , Jul 31, 2024.
- Whitelist: link
- Benefits: Exclusive Reward
#SingSing#Chickizen#BetaTest#Whitelist#GameRewards
📢 BETA TEST is coming soon!
We know you're itching to have a go and acquire your first CAThlete 🐷 Great news: gameplay development is progressing, and we're preparing a 💥playable beta💥!
We are grateful for your patience and will announce the start of beta testing in advance⏰ Stay tuned and don't miss out on the fun!
🐦 twitter: https://twitter.com/walken_io
🧨 medium https://medium.com/@walken.io
🕹️ discord https://discord.gg/QJDnFt6S4J
#nft#walken#walkandearn#NFTGaming#blockchaingame#betatest#betatester