[Kde-games-devel] KBreakout's QML port

Ian Wadham iandw.au at gmail.com
Sat Jan 5 21:30:03 UTC 2013


On 05/01/2013, at 7:51 PM, Viranch Mehta wrote:
> On 05-Jan-2013, at 1:43 PM, Wolfgang Rohdewald wrote:
>> Am Samstag, 5. Januar 2013, 11:17:21 schrieb Viranch Mehta:
>>> This is because it has to calculate the maximum size of the score text which can be fit in the box. 
>> 
>>           fm = QFontMetrics(self.painter.font())
>>           strLen = fm.width('the score text')
> 
> I should get the painter object by myDeclarativeView->paintEngine()->painter() , i suppose.
> 
> also, often i'm more interested in the height of the text (its always the height of the text that limits the font size to fit the text in the box) - which I can get from fm.height() I guess.

Dunno much about QML, but you can get the current font from any QWidget's
font() property.  It inherits whatever is set in the environment, via QApplication.
See the Qt doco for QWidget's font property.

Cheers, Ian W.



More information about the kde-games-devel mailing list