uranusjr / Qelly

Beautiful cross-platform BBS client.
61 stars 14 forks source link

以 RGB 儲存色碼,不要直接把 QColor 轉成 QVariant #78

Open uranusjr opened 10 years ago

uranusjr commented 10 years ago

Extracted from #77.

RGBA 與 QColor 的互換是 lossless,可行。Qt 本身在把 QColor 轉成 QVariant 時似乎本來就會用 RGB,所以直接 QColor->QVariant->QString 就會是 #RRGGBB 的格式,而這剛好(?) 也是 QColor 的 name 格式。不管是哪種,反正

QVariant v = [read color from settings...];
return QColor(v.toString());

這樣似乎保證可以。