[RQt-devel] qstrWidth() outside the paintFun()

Yihui Xie xieyihui at gmail.com
Thu Oct 14 18:49:16 CEST 2010


Hi,

We can calculate the width of a string inside the paintFun(layer,
painter) since qstrWIdth() needs the 'painter' argument. I wonder if
we can calculate the width when we only have the layer object, e.g.

s <- qscene()
test_layer <- qlayer(s, function(layer, painter) {
    qdrawRect(painter, 10, 10, 90, 90, stroke = 'blue')
    qstrWidth(painter, 'this is a string')
}, limits=qrect(0,0,100,100))
## what if we are outside?
qstrWidth(??, 'this is a string')

I want to automatically adjust the plot margins according to the width
and height of axis labels. Is there any way to calculate the height of
a string?

Thanks!

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA


More information about the Qtinterfaces-devel mailing list