PDA

View Full Version : What does "pad" mean for QColor?



hxcan
28th December 2011, 02:34
I'm reading the documentation of "Serializing Qt Data Types".
I found that when serializing a QColor , QDataStream outputs the following things:spec,alpha,red,green,blue,pad.

What does the pad value mean for a QColor? And what does pad mean for a real-life color?

mvuori
28th December 2011, 08:35
See: http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/painting/qcolor.h

I guess it is just nonsignificant "padding" to get the size of all alternative representations of color have the same number of bytes (see the unions in QColor class).

hxcan
28th December 2011, 12:21
I have read the implementation of QColor. "pad" is just set to 0 in the constructors . So I think you are right.
And I think the serialization of pad is not necessary . Is that right? It's always 0.



See: http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/painting/qcolor.h

I guess it is just nonsignificant "padding" to get the size of all alternative representations of color have the same number of bytes (see the unions in QColor class).

Added after 1 32 minutes:

I just thought about it again. The serialization of pad is necessary. Because QDataStream is serializing the whole union , which is not always rgb. The explaination of the union depends on spec . Pad is not always 0.


I have read the implementation of QColor. "pad" is just set to 0 in the constructors . So I think you are right.
And I think the serialization of pad is not necessary . Is that right? It's always 0.