[RQt-devel] layout issues

Hadley Wickham hadley at rice.edu
Tue Oct 5 20:49:24 CEST 2010


Looks good.  Will you add that example to the vignette?

What do you think about moving the currently intro pdf to the wiki?

Hadley

On Tue, Oct 5, 2010 at 1:07 PM, Michael Lawrence
<lawrence.michael at gene.com> wrote:
> Looked a bit into the layout issues. I've found that the following script
> gives a fairly desirable result. Forget about the stretch factor stuff for
> now, because unless a maximum or fixed size is set for a row/column, there
> is no guarantee that the row/column will not expand.
>
> library(qtpaint)
>
> fill_painter <- function(color) {
>   function(item, painter) qdrawRect(painter, 0, 0, 1, 1, fill = color)
> }
>
> layout_layer <- function(Color, ...) {
>   qlayer(figLayer, fill_painter(Color), limits = qrect(0, 0, 1, 1), ...)
> }
>
> scene <- qscene()
> figLayer <- qlayer(scene)
> layout <- figLayer$gridLayout()
>
> titleLayer <- layout_layer("red", colSpan = 2)
> yaxisLayer <- layout_layer("blue", row = 1)
> plotLayer <- layout_layer("green", row = 1, col = 1)
> xaxisLayer <- layout_layer("yellow", row = 2, col = 1)
>
> ## Set the maximum widths/heights:
>
> layout$setRowMaximumHeight(0, 50)
> layout$setColumnMaximumWidth(0, 50)
> layout$setRowMaximumHeight(2, 50)
>
> ## Could use Preferred here, with stretch factor set to zero, but this
> ## breaks when a layer spans multiple cells. It is hard to say if this
> ## is a bug in Qt, since QGraphicsGridLayout is largely
> ## undocumented. QGridLayout says a stretch-zero row/column can grow
> ## when no other row/column can grow. Setting a fixed or minimum
> ## width/height probably sets undue restrictions on the layout. The
> ## user should be able to shrink the window down, even if it is not
> ## longer possible to draw the data effectively. Thus, it's probably
> ## best to set the maximum.
>
> ## It is probably cleaner to set the dimensions directly on the layer:
> ## titleLayer$setMaximumHeight(50)
> ## xaxisLayer$setMaximumHeight(50)
> ## yaxisLayer$setMaximumWidth(50)
> ## But this currently crashes due to a (reported) bug in Smoke.
>
> qplotView(scene)
>
>
>
> _______________________________________________
> Qtinterfaces-devel mailing list
> Qtinterfaces-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel
>
>



-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/


More information about the Qtinterfaces-devel mailing list