void ItemHandlerColor::SetValue (QWidget *widget, const QVariant& value) const { ColorPicker *colorPicker = qobject_cast<ColorPicker*> (widget); if (!colorPicker) { qWarning () << Q_FUNC_INFO << "not a ColorPicker" << widget; return; } colorPicker->SetCurrentColor (value.value<QColor> ()); }
void ItemHandlerColor::Handle (const QDomElement& item, QWidget *pwidget) { QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ()); QString labelString = XSD_->GetLabel (item); QLabel *label = new QLabel (labelString); label->setWordWrap (false); ColorPicker *picker = new ColorPicker (labelString); picker->setObjectName (item.attribute ("property")); picker->SetCurrentColor (XSD_->GetValue (item).value<QColor> ()); connect (picker, SIGNAL (currentColorChanged (const QColor&)), this, SLOT (updatePreferences ())); picker->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this)); int row = lay->rowCount (); lay->setColumnMinimumWidth (0, 10); lay->setColumnStretch (0, 1); lay->setColumnStretch (1, 10); lay->addWidget (label, row, 0); lay->addWidget (picker, row, 1, Qt::AlignLeft); }