I want to extend QLCDNumber to show unit (like Deg/Rad/Grad selector in old calculator) along with the number. As I see it in high-level, to be style-independent, one should extend drawing area but restrict QLCDNumber to draw on the extended region. Then paint the required.
Another approach could be to create a compound widget wiht QLCDNumber without a frame and having the compound widget filled the same background color and drawing the additional text outside QLCDNumber.
Yet, another approach is to overload setValue() s.t. the last digit would be empty and then draw units there (or even use QLabel inside).
What is the best way of making things work and be as much style-independent as possible?
Thank you!
If you don't mind the units being displayed within the digit area, and you're content with the chars that
QLCDNumber
already provides, you can preformat your number + unit text and set it as string.Otherwise I'd suggest to pack a
QLCDNumber
and aQLabel
widget into a custom compound widget with a horizontal layout which you can provide with the methods needed, e. g.