Qt 4.8
Functions | Variables
qcursor.cpp File Reference
#include "qcursor.h"
#include <qapplication.h>
#include <qbitmap.h>
#include <qimage.h>
#include <qdatastream.h>
#include <qvariant.h>
#include <private/qcursor_p.h>

Go to the source code of this file.

Variables

QCursorDataqt_cursorTable [Qt::LastCursor+1]
 

Function Documentation

◆ operator<<()

QDataStream& operator<< ( QDataStream s,
const QCursor c 
)
related

Definition at line 255 of file qcursor.cpp.

256 {
257  s << (qint16)c.shape(); // write shape id to stream
258  if (c.shape() == Qt::BitmapCursor) { // bitmap cursor
259  bool isPixmap = false;
260  if (s.version() >= 7) {
261  isPixmap = !c.pixmap().isNull();
262  s << isPixmap;
263  }
264  if (isPixmap)
265  s << c.pixmap();
266  else
267  s << *c.bitmap() << *c.mask();
268  s << c.hotSpot();
269  }
270  return s;
271 }
short qint16
Definition: qglobal.h:935
QPixmap pixmap() const
Returns the cursor pixmap.
Definition: qcursor.cpp:528
int version() const
Returns the version number of the data serialization format.
Definition: qdatastream.h:212
QPoint hotSpot() const
Returns the cursor hot spot, or (0, 0) if it is one of the standard cursors.
Definition: qcursor.cpp:540
const QBitmap * bitmap() const
Returns the cursor bitmap, or 0 if it is one of the standard cursors.
Definition: qcursor.cpp:504
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
const QBitmap * mask() const
Returns the cursor bitmap mask, or 0 if it is one of the standard cursors.
Definition: qcursor.cpp:516
Qt::CursorShape shape() const
Returns the cursor shape identifier.
Definition: qcursor.cpp:469

◆ operator>>()

QDataStream& operator>> ( QDataStream s,
QCursor c 
)
related

Definition at line 285 of file qcursor.cpp.

286 {
287  qint16 shape;
288  s >> shape; // read shape id from stream
289  if (shape == Qt::BitmapCursor) { // read bitmap cursor
290  bool isPixmap = false;
291  if (s.version() >= 7)
292  s >> isPixmap;
293  if (isPixmap) {
294  QPixmap pm;
295  QPoint hot;
296  s >> pm >> hot;
297  c = QCursor(pm, hot.x(), hot.y());
298  } else {
299  QBitmap bm, bmm;
300  QPoint hot;
301  s >> bm >> bmm >> hot;
302  c = QCursor(bm, bmm, hot.x(), hot.y());
303  }
304  } else {
305  c.setShape((Qt::CursorShape)shape); // create cursor with shape
306  }
307  return s;
308 }
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
short qint16
Definition: qglobal.h:935
int version() const
Returns the version number of the data serialization format.
Definition: qdatastream.h:212
CursorShape
Definition: qnamespace.h:1262
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void setShape(Qt::CursorShape newShape)
Sets the cursor to the shape identified by shape.
Definition: qcursor.cpp:483

Variable Documentation

◆ qt_cursorTable

QCursorData* qt_cursorTable[Qt::LastCursor+1]

Definition at line 398 of file qcursor.cpp.

Referenced by QCursor::QCursor(), and QCursorData::setBitmap().