QSize(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

✨ NAME ✨

QSize β€” okay so this is the QSize(3qt) page bestie, and it's literally just this: it defines the size of a two-dimensional object. that's it. that's the whole vibe. πŸ’…


🌸 SYNOPSIS 🌸

#include <qsize.h>

πŸ’– Public Members πŸ’–

enum ScaleMode { ScaleFree, ScaleMin, ScaleMax }
QSize ()
QSize ( int w, int h )
bool isNull () const
bool isEmpty () const
bool isValid () const
int width () const
int height () const
void setWidth ( int w )
void setHeight ( int h )
void transpose ()
void scale ( int w, int h, ScaleMode mode )
void scale ( const QSize & s, ScaleMode mode )
QSize expandedTo ( const QSize & otherSize ) const
QSize boundedTo ( const QSize & otherSize ) const
QCOORD & rwidth ()
QCOORD & rheight ()
QSize & operator+= ( const QSize & s )
QSize & operator-= ( const QSize & s )
QSize & operator*= ( int c )
QSize & operator*= ( double c )
QSize & operator/= ( int c )
QSize & operator/= ( double c )
bool operator== ( const QSize & s1, const QSize & s2 )
bool operator!= ( const QSize & s1, const QSize & s2 )
const QSize operator+ ( const QSize & s1, const QSize & s2 )
const QSize operator- ( const QSize & s1, const QSize & s2 )
const QSize operator* ( const QSize & s, int c )
const QSize operator* ( int c, const QSize & s )
const QSize operator* ( const QSize & s, double c )
const QSize operator* ( double c, const QSize & s )
const QSize operator/ ( const QSize & s, int c )
const QSize operator/ ( const QSize & s, double c )
QDataStream & operator<< ( QDataStream & s, const QSize & sz )
QDataStream & operator>> ( QDataStream & s, QSize & sz )

πŸ‘‘ DESCRIPTION πŸ‘‘

The QSize class defines the size of a two-dimensional object. no cap.

A size is specified by a width and a height. two numbers. iconic duo behavior tbh.

The coordinate type is QCOORD (defined in <qwindowdefs.h> as int). The minimum value of QCOORD is QCOORD_MIN (-2147483648) and the maximum value is QCOORD_MAX (2147483647). so like. it can go very negative and very positive. main character range fr. 😭

You can set the size in the constructor and change it with setWidth() and setHeight(), or use operator+=(), operator-=(), operator*=() and operator/=(), etc. You can swap the width and height with transpose(). You can get a size that holds the maximum height and width of two sizes using expandedTo(), and the minimum height and width of two sizes using boundedTo(). 🫢

See also QPoint, QRect, Graphics Classes, and Image Processing Classes.


πŸŽ€ Member Type Documentation πŸŽ€

πŸ’œ QSize::ScaleMode πŸ’œ

This enum type defines the different ways of scaling a size.

(there's an image here in the original and it got omitted, so just imagine a very cute diagram bestie πŸ–ΌοΈβœ¨)
  • QSize::ScaleFree β€” The size is scaled freely. The ratio is not preserved. do whatever you want, no rules. πŸ™ˆ
  • QSize::ScaleMin β€” The size is scaled to a rectangle as large as possible inside a given rectangle, preserving the aspect ratio.
  • QSize::ScaleMax β€” The size is scaled to a rectangle as small as possible outside a given rectangle, preserving the aspect ratio.

See also QSize::scale(), QImage::scale(), and QImage::smoothScale().


πŸ’… MEMBER FUNCTION DOCUMENTATION πŸ’…

⭐ QSize::QSize ()

Constructs a size with invalid (negative) width and height. yeah. negative. it's giving "uninitialized but make it drama". 😭

⭐ QSize::QSize ( int w, int h )

Constructs a size with width w and height h. the classic. the standard. we love her. πŸ’–

⭐ QSize QSize::boundedTo ( const QSize & otherSize ) const

Returns a size with the minimum width and height of this size and otherSize.

⭐ QSize QSize::expandedTo ( const QSize & otherSize ) const

Returns a size with the maximum width and height of this size and otherSize.

Examples:

⭐ int QSize::height () const

Returns the height. πŸ“

See also width().

Examples:

⭐ bool QSize::isEmpty () const

Returns TRUE if the width is less than or equal to 0, or the height is less than or equal to 0; otherwise returns FALSE.

⭐ bool QSize::isNull () const

Returns TRUE if the width is 0 and the height is 0; otherwise returns FALSE.

⭐ bool QSize::isValid () const

Returns TRUE if the width is equal to or greater than 0 and the height is equal to or greater than 0; otherwise returns FALSE.

⭐ QSize & QSize::operator*= ( int c )

Multiplies both the width and height by c and returns a reference to the size.

⭐ QSize & QSize::operator*= ( double c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Multiplies both the width and height by c and returns a reference to the size.

Note that the result is truncated. 😬

⭐ QSize & QSize::operator+= ( const QSize & s )

Adds s to the size and returns a reference to this size.

Example:

QSize s(  3, 7 );
QSize r( -1, 4 );
s += r;                     // s becomes (2,11)

⭐ QSize & QSize::operator-= ( const QSize & s )

Subtracts s from the size and returns a reference to this size.

Example:

QSize s(  3, 7 );
QSize r( -1, 4 );
s -= r;                     // s becomes (4,3)

⭐ QSize & QSize::operator/= ( int c )

Divides both the width and height by c and returns a reference to the size.

⭐ QSize & QSize::operator/= ( double c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Divides both the width and height by c and returns a reference to the size.

Note that the result is truncated. 🫠

⭐ QCOORD & QSize::rheight ()

Returns a reference to the height.

Using a reference makes it possible to directly manipulate the height. you get to touch it. directly. πŸ’…

Example:

QSize s( 100, 10 );
s.rheight() += 5;           // s becomes (100,15)

See also rwidth().

⭐ QCOORD & QSize::rwidth ()

Returns a reference to the width.

Using a reference makes it possible to directly manipulate the width.

Example:

QSize s( 100, 10 );
s.rwidth() += 20;           // s becomes (120,10)

See also rheight().

⭐ void QSize::scale ( int w, int h, ScaleMode mode )

Scales the size to a rectangle of width w and height h according to the ScaleMode mode.

  • If mode is ScaleFree, the size is set to (w, h). no thoughts, just vibes.
  • If mode is ScaleMin, the current size is scaled to a rectangle as large as possible inside (w, h), preserving the aspect ratio.
  • If mode is ScaleMax, the current size is scaled to a rectangle as small as possible outside (w, h), preserving the aspect ratio.

Example:

QSize t1( 10, 12 );
t1.scale( 60, 60, QSize::ScaleFree );
// t1 is (60, 60)
QSize t2( 10, 12 );
t2.scale( 60, 60, QSize::ScaleMin );
// t2 is (50, 60)
QSize t3( 10, 12 );
t3.scale( 60, 60, QSize::ScaleMax );
// t3 is (60, 72)

⭐ void QSize::scale ( const QSize & s, ScaleMode mode )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Equivalent to scale(s.width(), s.height(), mode).

⭐ void QSize::setHeight ( int h )

Sets the height to h.

See also height() and setWidth().

⭐ void QSize::setWidth ( int w )

Sets the width to w.

See also width() and setHeight().

⭐ void QSize::transpose ()

Swaps the values of width and height. πŸ”„ glow-up but it's just geometry.

⭐ int QSize::width () const

Returns the width. πŸ“

See also height().

Examples:


πŸ’– bool operator!= ( const QSize & s1, const QSize & s2 )

Returns TRUE if s1 and s2 are different; otherwise returns FALSE.

πŸ’– const QSize operator* ( const QSize & s, int c )

Multiplies s by c and returns the result.

πŸ’– const QSize operator* ( int c, const QSize & s )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Multiplies s by c and returns the result.

πŸ’– const QSize operator* ( const QSize & s, double c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Multiplies s by c and returns the result.

πŸ’– const QSize operator* ( double c, const QSize & s )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Multiplies s by c and returns the result.

πŸ’– const QSize operator+ ( const QSize & s1, const QSize & s2 )

Returns the sum of s1 and s2; each component is added separately.

πŸ’– const QSize operator- ( const QSize & s1, const QSize & s2 )

Returns s2 subtracted from s1; each component is subtracted separately.

πŸ’– const QSize operator/ ( const QSize & s, int c )

Divides s by c and returns the result.

πŸ’– const QSize operator/ ( const QSize & s, double c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Divides s by c and returns the result.

Note that the result is truncated. πŸ’€

πŸ’– QDataStream & operator<< ( QDataStream & s, const QSize & sz )

Writes the size sz to the stream s and returns a reference to the stream.

See also Format of the QDataStream operators.

πŸ’– bool operator== ( const QSize & s1, const QSize & s2 )

Returns TRUE if s1 and s2 are equal; otherwise returns FALSE.

πŸ’– QDataStream & operator>> ( QDataStream & s, QSize & sz )

Reads the size from the stream s into size sz and returns a reference to the stream.

See also Format of the QDataStream operators.


πŸ¦‹ SEE ALSO πŸ¦‹


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. πŸ“œ


⭐ AUTHOR ⭐

Generated automatically from the source code. (so nobody's personal blorbo wrote this, it's a machine. iconic.)


πŸ’€ BUGS πŸ’€

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. 🫢

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. 😭

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qsize.3qt) and the Qt version (3.3.8).


Trolltech AS Β· 2 February 2007 Β· QSize(3qt) β€” and that's the whole page bestie, go forth and size things responsibly πŸ’–βœ¨πŸ¦‹πŸŽ€πŸ’…

πŸ“¦ where this page comes from