2013-02-21 11 views
7

宣言QVariant :: QVariant(Qtの:: GlobalColor)は、」プライベート

QColor dialogBoja, dialogBoja1; 

ヘッダ・ファイル内の.cppファイル

dialogBoja = postavke.value("boja", Qt::black).toString(); 
//postavke means settings 
dialogBoja1 = postavke.value("boja1", Qt::white).toString(); 

ですQt5私はエラーが発生します:QVariant :: QVariant(Qt :: GlobalColor) 'はプライベートです

これを解決する方法。

答えて

9

明示的にQColorオブジェクトを作成する必要があります。これは動作するはずです:

dialogBoja = postavke.value("boja", QColor(Qt::black)).toString(); 

その理由は、ヘッダーに説明されている:彼らはQColorのように、QtGuiモジュールからQVariantと離婚したかった、と5.0で、そのコンストラクタを取り除くよう

// These constructors don't create QVariants of the type associcated 
// with the enum, as expected, but they would create a QVariant of 
// type int with the value of the enum value. 
// Use QVariant v = QColor(Qt::red) instead of QVariant v = Qt::red for 
// example. 
3

が見えます。いくつかの構文はhereと説明されています。

Because QVariant is part of the QtCore library, it cannot provide conversion functions to data types defined in QtGui, such as QColor, QImage, and QPixmap. In other words, there is no toColor() function. Instead, you can use the QVariant::value() or the qvariant_cast() template function.

関連する問題