JimDaniel
3rd June 2008, 03:00
I'm wanting to create more graphical text to put on our QPushButtons and QLabels. I mean text with effects, like gradients...outlines...etc.
How would you gurus recommend approaching something like this? I'd like to avoid pre-creating images for all the text I'll need, as we'll need to translate it later on. I know QPainter can achieve all the effects I need.
Would the best method be to get the region of the button or label I want the graphical text on, then use QPainter to paint the text I need inside the area? That was my initial thought, but somehow I don't like that.
Thanks for any help you can give, Daniel
EDIT: Been reading up on QPainter - I notice it can take a QPaintDevice in its constructor as the object to paint to. Looking at QPaintDevice I see that QPixmap implements it. Would it be feasible (efficient) to paint my graphical text to a QPixmap object, then set the QPixmap as the button's icon? I'm going to experiment of course, just want to do it the best possible way.
How would you gurus recommend approaching something like this? I'd like to avoid pre-creating images for all the text I'll need, as we'll need to translate it later on. I know QPainter can achieve all the effects I need.
Would the best method be to get the region of the button or label I want the graphical text on, then use QPainter to paint the text I need inside the area? That was my initial thought, but somehow I don't like that.
Thanks for any help you can give, Daniel
EDIT: Been reading up on QPainter - I notice it can take a QPaintDevice in its constructor as the object to paint to. Looking at QPaintDevice I see that QPixmap implements it. Would it be feasible (efficient) to paint my graphical text to a QPixmap object, then set the QPixmap as the button's icon? I'm going to experiment of course, just want to do it the best possible way.