Есть у QLabel есть одна особенность. Её минимальный размер определяется текстом, который в неё записан. Это приводит к тому что длинный текст принудительно увеличивает ширину интерфейса.
В большинстве случаев это выглядит плохо.
Как с этим бороться?
🔸 Обрезать текст заранее, задав лимит по длине строки. В этом случае мы теряем часть визуальной информации. Не всегда угадаешь нужный размер. В разных OS шрифт используется разный.
🔸 Делать перенос строки. Тогда мы получим изменение размера в другую сторону, что тоже поломает интерфейс.
🔸 Переопределить paintEvent() и сделать кастомный рендеринг текста. Можно, но слишком сложно для такой задачи.
Проще всего обрезать текст под текущий размер виджета используя класс QFontMetrics.
Он имеет готовый метод elidedText(), который просто вызываем по событию resizeEvent.
Я также добавил установку ToolTip чтобы всегда можно было увидеть полный текст при наведении курсора.
🌎 Код здесь
#qt#source
ℹ️How Callegram Business Works Right Now
In previous post we told you how to setup a Callegram Business account. Today we're sharing with you what you'll get after new status:
⚙️Notifications Settings. When your customer will book a call, you can setup a specific time presets for notifications. To find all notification settings you can view Profile section inside @CallegramBot Mini App;
💬Automated Replies. At this moment your schedule is sent when your customer asks you about it. If in customer's questions will contain these words: «Schedule, Appointment, Booking, Book» — @CallegramBot will send your schedule instantly. Check the video above to see how it works.
Ask us anything about Callegram Business and we will help you!
#CallegramBusiness#MiniApps#Business
ℹ️How to Setup Callegram Business
1. Open Telegram settings;
2. Tap on «Telegram Business» button;
3. Find «Chat Bots» section;
4. Enter CallegramBot into special field and tap on the button «Add»
✔️ Done. Now your Callegram profile is in Business mode.
⚙️ Don't forget to setup your working hours in Telegram Business menu.
#CallegramBusiness#Business#MiniApps
🤫Page Of Businesses
Users, are you ready to make appointments in a few clicks?
Businesses, are you ready to provide your services seamlessly?
🙂 Stay tuned
#Appointments#MiniApps#Business#CallegramBusiness
👍 Make Us Better
We've been growing fast and we want to give you the best experience if you use @CallegramBot.
We've sent a special feedback form to all our Business users. If you want to help us make Callegram better, please fill in the form below:
🔗https://t.me/CallegramBot/feedback
P.S. Don't forget share with us your the most desirable function
#TelegramBusiness#CallegramBusiness#MiniApps#Web_Apps