constructors: Convenience constructors

Description Usage Arguments Details Value Author(s) Examples

Description

These functions construct some simple Qt helper objects. They offer convenience beyond that of the native constructor, largely because they might coerce from an R equivalent to a Qt object. Also, unlike C++, argument skipping is supported.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
qrect(x0, y0, x1, y1)
qpoint(x, y)
qsize(width, height)
qpolygon(x = NULL, y = NULL)
qfont(family = baseFont$family(), pointsize =
      baseFont$pointSize(), weight = baseFont$weight(),
      italic = baseFont$style() == Qt$QFont$StyleItalic,
      baseFont = Qt$QApplication$font())
qpen(brush = qbrush(), width = 0L, style = Qt$Qt$SolidLine,
                 cap = Qt$Qt$SquareCap, join = Qt$Qt$BevelJoin)
qbrush(color = qcolor(), style = Qt$Qt$SolidPattern)
qcolor(red = 0, green = 0, blue = 0, alpha = 255)
qtransform(m11 = 1.0, m12 = 0.0, m13 = 0.0, m21 = 0.0, m22 = 1.0,
           m23 = 0.0, m31 = 0.0, m32 = 0.0, m33 = 1.0)

Arguments

x0

Top-left X coordinate. If a vector of length two, taken as x0 and x1. If a 2x2 matrix, the columns represent the X and Y positions. If missing, a "null" rectangle is returned.

y0

Top-left Y coordinate. If a vector of length two, taken as y0 and y1.

x1

Bottom-right X coordinate.

y1

Bottom-right Y coordinate.

x

X coordinate. If a vector of length two, taken as x and y. For qpolygon, passed to xy.coords.

y

Y coordinate. For qpolygon, passed to xy.coords.

width

Width for the size. If a vector of length two, taken as width and height. If missing, a "null" size is returned. For qpen, width of the line.

height

Height for the size.

family

Font family name.

pointsize

Font point size.

weight

Font weight (bold).

italic

Whether font is italicized.

baseFont

The base font to use for the defaults. By default, this is the global application font.

brush

Something coercible to a QBrush object via qbrush(brush).

style

Line dashing for qpen, pattern type for qbrush.

cap

Line cap style.

join

Line join style.

color

Something coercible to a QColor via qcolor(color).

red

Red component, 0-255. If a string, taken as color name and converted. If a matrix, taken as output of col2rgb.

green

Green component, 0-255.

blue

Blue component, 0-255.

alpha

Alpha component, 0-255.

m11

Horizontal scaling factor

m12

Vertical shearing factor

m13

Horizontal projection factor

m21

Horizontal shearing factor

m22

Vertical scaling factor

m23

Vertical projection factor

m31

Horizontal translation factor

m32

Vertical translation factor

m33

Division factor

Details

For structures with a F variant, like QSizeF, the variant is chosen based on the type of the input. If the values are double, a QSizeF instance is returned, otherwise an instance of QSize.

Value

An instance, RQtObject

Author(s)

Michael Lawrence, Deepayan Sarkar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## notice the coercion chaining:
redColor <- qcolor("red")
redBrush <- qbrush("red")
redPen <- qpen("red")
blackPen <- qpen()

## Qt's constructor uses width/height, not x1/y1
rect <- qrect(as.matrix(Qt$QRectF(1, 1, 5, 5)))
as.matrix(rect)

## Creates 'QRect' not 'QRectF'; integer input
qrect(range(1:10), range(2:5))

qsize(as.vector(qpoint(5, 5)))

mono_it <- qfont("monospace", italic = TRUE)

qtbase documentation built on May 2, 2019, 9:58 a.m.