Qt 4.8
Classes | Functions
qcolor.h File Reference
#include <QtGui/qrgb.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qstringlist.h>

Go to the source code of this file.

Classes

class  QColor
 The QColor class provides colors based on RGB, HSV or CMYK values. More...
 

Functions

Q_GUI_EXPORT QDebug operator<< (QDebug, const QColor &)
 
Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QColor &)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, QColor &)
 

Function Documentation

◆ operator<<() [1/2]

Q_GUI_EXPORT QDebug operator<< ( QDebug  ,
const QColor  
)

Definition at line 2602 of file qcolor.cpp.

2603 {
2604 #ifndef Q_BROKEN_DEBUG_STREAM
2605  if (!c.isValid())
2606  dbg.nospace() << "QColor(Invalid)";
2607  else if (c.spec() == QColor::Rgb)
2608  dbg.nospace() << "QColor(ARGB " << c.alphaF() << ", " << c.redF() << ", " << c.greenF() << ", " << c.blueF() << ')';
2609  else if (c.spec() == QColor::Hsv)
2610  dbg.nospace() << "QColor(AHSV " << c.alphaF() << ", " << c.hueF() << ", " << c.saturationF() << ", " << c.valueF() << ')';
2611  else if (c.spec() == QColor::Cmyk)
2612  dbg.nospace() << "QColor(ACMYK " << c.alphaF() << ", " << c.cyanF() << ", " << c.magentaF() << ", " << c.yellowF() << ", "
2613  << c.blackF()<< ')';
2614  else if (c.spec() == QColor::Hsl)
2615  dbg.nospace() << "QColor(AHSL " << c.alphaF() << ", " << c.hslHueF() << ", " << c.hslSaturationF() << ", " << c.lightnessF() << ')';
2616 
2617  return dbg.space();
2618 #else
2619  qWarning("This compiler doesn't support streaming QColor to QDebug");
2620  return dbg;
2621  Q_UNUSED(c);
2622 #endif
2623 }
unsigned char c[8]
Definition: qnumeric_p.h:62
Q_CORE_EXPORT void qWarning(const char *,...)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ operator<<() [2/2]

Q_GUI_EXPORT QDataStream& operator<< ( QDataStream ,
const QColor  
)

Definition at line 2638 of file qcolor.cpp.

2639 {
2640  if (stream.version() < 7) {
2641  if (!color.isValid())
2642  return stream << quint32(0x49000000);
2643  quint32 p = (quint32)color.rgb();
2644  if (stream.version() == 1) // Swap red and blue
2645  p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
2646  return stream << p;
2647  }
2648 
2649  qint8 s = color.cspec;
2650  quint16 a = color.ct.argb.alpha;
2651  quint16 r = color.ct.argb.red;
2652  quint16 g = color.ct.argb.green;
2653  quint16 b = color.ct.argb.blue;
2654  quint16 p = color.ct.argb.pad;
2655 
2656  stream << s;
2657  stream << a;
2658  stream << r;
2659  stream << g;
2660  stream << b;
2661  stream << p;
2662 
2663  return stream;
2664 }
long ASN1_INTEGER_get ASN1_INTEGER * a
signed char qint8
Definition: qglobal.h:933
static FILE * stream
unsigned short quint16
Definition: qglobal.h:936
unsigned int quint32
Definition: qglobal.h:938

◆ operator>>()

Q_GUI_EXPORT QDataStream& operator>> ( QDataStream ,
QColor  
)

Definition at line 2677 of file qcolor.cpp.

2678 {
2679  if (stream.version() < 7) {
2680  quint32 p;
2681  stream >> p;
2682  if (p == 0x49000000) {
2683  color.invalidate();
2684  return stream;
2685  }
2686  if (stream.version() == 1) // Swap red and blue
2687  p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00);
2688  color.setRgb(p);
2689  return stream;
2690  }
2691 
2692  qint8 s;
2693  quint16 a, r, g, b, p;
2694  stream >> s;
2695  stream >> a;
2696  stream >> r;
2697  stream >> g;
2698  stream >> b;
2699  stream >> p;
2700 
2701  color.cspec = QColor::Spec(s);
2702  color.ct.argb.alpha = a;
2703  color.ct.argb.red = r;
2704  color.ct.argb.green = g;
2705  color.ct.argb.blue = b;
2706  color.ct.argb.pad = p;
2707 
2708  return stream;
2709 }
Spec
The type of color specified, either RGB, HSV, CMYK or HSL.
Definition: qcolor.h:70
long ASN1_INTEGER_get ASN1_INTEGER * a
signed char qint8
Definition: qglobal.h:933
static FILE * stream
unsigned short quint16
Definition: qglobal.h:936
unsigned int quint32
Definition: qglobal.h:938