|Home | Tutorial | Classes | Functions | QSA Workbench | Language | Qt API | QSA Articles Qt Script for Applications

[Prev: Built-in Operators] [Home] [Next: Arithmetic Operators]

Assignment Operators

These operators are used to assign the value of expressions to variables.

= operator

var variable = expression;

The assignment operator is used to assign the value of an expression to the variable.

It is an error to attempt to assign to a constant.

+= operator

variable += expression;

This operator adds the value of the expression to the variable. It is the same as:

    variable = variable + expression;

but is shorter to write, and less error-prone.

See also += string operator.

-= operator

variable -= expression;

This operator subtracts the value of the expression from the variable.

*= operator

variable *= expression;

This operator multiplies the value of the expression by the value of the variable.

/= operator

variable /= expression;

This operator divides the value of the variable by the value of the expression.

%= operator

variable %= expression;

This operator divides the variable by the expression, and assigns the remainder of the division (which may be 0), to the variable.

&= operator

variable &= expression;

This operator performs a bit-wise AND on the value of the expression and the value of the variable, and assigns the result to the variable.

^= operator

variable ^= expression;

This operator performs a bit-wise OR on the value of the expression and the value of the variable, and assigns the result to the variable.

|= operator

variable |= expression;

This operator performs a bit-wise OR on the value of the expression and the value of the variable, and assigns the result to the variable.

<<= operator

variable <<= expression;

This operator performs a bit-wise left shift on the variable by an expression number of bits. Zeros are shifted in from the right.

>>= operator

variable >>= expression;

This operator performs a bit-wise (sign-preserving) right shift on the variable by an expression number of bits.

>>>= operator

variable >>>= expression;

This operator performs a bit-wise (zero-padding) right shift on the variable by an expression number of bits.

[Prev: Built-in Operators] [Home] [Next: Arithmetic Operators]


Copyright © 2001-2006 TrolltechTrademarks
QSA version 1.1.5