Qt Jambi Home

com.trolltech.qt.core
Class QSize

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QSize
All Implemented Interfaces:
QtJambiInterface

public class QSize
extends QtJambiObject

The QSize class defines the size of a two-dimensional object using integer point precision.

A size is specified by a width and a height. It can be set in the constructor and changed using the setWidth, setHeight, or scale functions, or using arithmetic operators. A size can also be manipulated directly by retrieving references to the width and height using the rwidth() and rheight() functions. Finally, the width and height can be swapped using the transpose function.

The isValid function determines if a size is valid (a valid size has both width and height greater than zero). The isEmpty function returns true if either of the width and height is less than, or equal to, zero, while the isNull function returns true only if both the width and the height is zero.

Use the expandedTo function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, the boundedTo function returns a size which holds the minimum height and width of this size and a given size.

QSize objects can be streamed as well as compared.

See Also:
QSizeF, QPoint, QRect

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
QSize()
          Constructs a size with an invalid width and height (i.e., isValid returns false).
QSize(int w, int h)
          Constructs a size with the given w and h.
 
Method Summary
 QSize add(QSize s)
          Adds s to this QSize and returns the result.
 QSize boundedTo(QSize arg__1)
          Returns a size holding the minimum width and height of this size and the given arg__1.
 QSize divide(double d)
          Divides this QSize by divisor d and returns the result.
 boolean equals(java.lang.Object other)
          
 QSize expandedTo(QSize arg__1)
          Returns a size holding the maximum width and height of this size and the given arg__1.
static QSize fromNativePointer(QNativePointer nativePointer)
          This function returns the QSize instance pointed to by nativePointer
 int height()
          Returns the height.
 boolean isEmpty()
          Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
 boolean isNull()
          Returns true if both the width and height is 0; otherwise returns false.
 boolean isValid()
          Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
 QSize multiply(double d)
          Multiplies this QSize by factor d and returns the result.
static QNativePointer nativePointerArray(QSize[] array)
          This function returns a QNativePointer that is pointing to the specified QSize array.
 void readFrom(QDataStream arg__1)
          Reads a QSize from arg__1.
 void scale(int w, int h, Qt.AspectRatioMode mode)
          Scales the size to a rectangle with the given w and h, according to the specified mode:
 void scale(QSize s, Qt.AspectRatioMode mode)
          Scales the size to a rectangle with the given s, according to the specified mode.
 void setHeight(int h)
          Sets the height to the given h.
 void setWidth(int w)
          Sets the width to the given w.
 QSize subtract(QSize s)
          Subtracts s from this QSize and returns the result.
 void transpose()
          Swaps the width and height values.
 int width()
          Returns the width.
 void writeTo(QDataStream arg__1)
          Writes thisQSize to arg__1.
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QSize

public QSize(int w,
             int h)

Constructs a size with the given w and h.

See Also:
setWidth, setHeight

QSize

public QSize()

Constructs a size with an invalid width and height (i.e., isValid returns false).

See Also:
isValid
Method Detail

boundedTo

public final QSize boundedTo(QSize arg__1)

Returns a size holding the minimum width and height of this size and the given arg__1.

See Also:
expandedTo, scale

expandedTo

public final QSize expandedTo(QSize arg__1)

Returns a size holding the maximum width and height of this size and the given arg__1.

See Also:
boundedTo, scale

height

public final int height()

Returns the height.

See Also:
width, setHeight

isEmpty

public final boolean isEmpty()

Returns true if either of the width and height is less than or equal to 0; otherwise returns false.

See Also:
isNull, isValid

isNull

public final boolean isNull()

Returns true if both the width and height is 0; otherwise returns false.

See Also:
isValid, isEmpty

isValid

public final boolean isValid()

Returns true if both the width and height is equal to or greater than 0; otherwise returns false.

See Also:
isNull, isEmpty

writeTo

public final void writeTo(QDataStream arg__1)
Writes thisQSize to arg__1.


readFrom

public final void readFrom(QDataStream arg__1)
Reads a QSize from arg__1.


scale

public final void scale(QSize s,
                        Qt.AspectRatioMode mode)

Scales the size to a rectangle with the given s, according to the specified mode.


scale

public final void scale(int w,
                        int h,
                        Qt.AspectRatioMode mode)

Scales the size to a rectangle with the given w and h, according to the specified mode:

Example:

    QSize t1(10, 12);
    t1.scale(60, 60, Qt::IgnoreAspectRatio);
    // t1 is (60, 60)

    QSize t2(10, 12);
    t2.scale(60, 60, Qt::KeepAspectRatio);
    // t2 is (50, 60)

    QSize t3(10, 12);
    t3.scale(60, 60, Qt::KeepAspectRatioByExpanding);
    // t3 is (60, 72)

See Also:
setWidth, setHeight

setHeight

public final void setHeight(int h)

Sets the height to the given h.

See Also:
rheight, height, setWidth

setWidth

public final void setWidth(int w)

Sets the width to the given w.

See Also:
rwidth, width, setHeight

transpose

public final void transpose()

Swaps the width and height values.

See Also:
setWidth, setHeight

width

public final int width()

Returns the width.

See Also:
height, setWidth

fromNativePointer

public static QSize fromNativePointer(QNativePointer nativePointer)
This function returns the QSize instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

nativePointerArray

public static QNativePointer nativePointerArray(QSize[] array)
This function returns a QNativePointer that is pointing to the specified QSize array.

Parameters:
array - the array that the returned pointer will point to.
Returns:
a QNativePointer that is pointing to the specified array.

equals

public boolean equals(java.lang.Object other)

Overrides:
equals in class java.lang.Object

multiply

public final QSize multiply(double d)
Multiplies this QSize by factor d and returns the result.


divide

public final QSize divide(double d)
Divides this QSize by divisor d and returns the result.


add

public final QSize add(QSize s)
Adds s to this QSize and returns the result.


subtract

public final QSize subtract(QSize s)
Subtracts s from this QSize and returns the result.


Qt Jambi Home