Learn R Programming

qtbase (version 1.1.0)

RQtObject: Instance of a Class

Description

Represents an instance of a class, as a special type of environment. In this case, the members are methods and, for QObject-derivatives, properties.

Arguments

Details

The ordinary environment API is supported, with restrictions on assignments. Retrieve objects with $ or get. Replacing a method is not supported. For QObject instances, the members include the properties, which may be set through assignment, e.g., with the $<- method.

C++ operators are also supported, with the familiar syntax. Most C++ operators have obvious R equivalents. Two exceptions are the >> and << operators, which are defined as the infix functions %>>% and %<<%< code=""> in R.

Some classes in the Qt API are light-weight, and their instances are usually treated as values. For some of the most prevalent of these types, we define coercion methods to convenient R equivalents. Below, we list the R type corresponding to each Qt type. Coercion methods are defined for the conventional generic for the type, e.g., as.integer for integers. For those types with a variant ending in F, like QSizeF, the F variant yields double values in R, while QSize would be integer.

[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

See Also

RQtClass (for constructing instances)

Examples

Run this code
widget <- Qt$QWidget()
widget$setWindowTitle("Hello World")
widget$windowTitle # access a property
widget$windowTitle <- "Hello Again"

size <- qsize(2L, 3L)
as.integer(size * 2) # operators work too
as.integer(size) * 2

Run the code above in your browser using DataLab