Есть у QLabel есть одна особенность. Её минимальный размер определяется текстом, который в неё записан. Это приводит к тому что длинный текст принудительно увеличивает ширину интерфейса.
В большинстве случаев это выглядит плохо.
Как с этим бороться?
🔸 Обрезать текст заранее, задав лимит по длине строки. В этом случае мы теряем часть визуальной информации. Не всегда угадаешь нужный размер. В разных OS шрифт используется разный.
🔸 Делать перенос строки. Тогда мы получим изменение размера в другую сторону, что тоже поломает интерфейс.
🔸 Переопределить paintEvent() и сделать кастомный рендеринг текста. Можно, но слишком сложно для такой задачи.
Проще всего обрезать текст под текущий размер виджета используя класс QFontMetrics.
Он имеет готовый метод elidedText(), который просто вызываем по событию resizeEvent.
Я также добавил установку ToolTip чтобы всегда можно было увидеть полный текст при наведении курсора.
🌎 Код здесь
#qt#source
#ARPA/USDT analysis :
#ARPA is currently moving upward within a bullish channel, consistently forming higher highs (HHs) and higher lows (HLs). The price has recently rebounded from the support of the channel and is expected to test the resistance level of the channel soon.
TF : 4H
Entry : $0.05590
Target : $0.06165
SL : $0.05187
#ARPA/USDT Analysis-
ARPA has formed bullish symmetrical triangle pattern. Once it will break the high then it has high potential to go up till the target zone.
T.F.- 4-H
ENTRY- as soon as it gives breakout
SL- 0.04610
TARGET- 0.05500
Note: If the stop-loss is triggered before entry, disregard the trade as the price action may develop differently.
#ARPA/USDT analysis -
#ARPA is making new lows, the price is currently consolidating near the resistance zone. Wait for a pullback towards the resistance zone and wait for the price to be rejected from the zone for a short entry. The previous low is expected to be tested.
TF : 2h
Entry : $0.0486
Target : $0.0442
SL : $0.0506
#ARPA/USDT ANALYSIS
ARPA is currently consolidating within a descending triangle, with a rebound occurring from the horizontal demand zone at the base of the pattern.
The Ichimoku Cloud serves as a resistance overhead, situated above the triangle. A decisive move, either a breakout or breakdown, is needed before considering any trades.