Passing QLinearGradient as Property from QSS
Hi all,
I'm having a bit of an issue and I'm hoping one of you can help to shed some light on what I'm doing wrong.
What I'm trying to do: pass a QLinearGradient as a custom property to a class from QSS. I'm able to pass many other data types as QProperties via QSS without issue.
What happens: the set method is never called even when the property is set via the QSS.
For example, I do this:
Code:
#include <QFrame>
#include <QColor>
#include <QLinearGradient>
#include <QDebug>
namespace Ui {
class Foo;
}
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor DESIGNABLE
true) Q_PROPERTY(QLinearGradient fillColor READ fillColor WRITE setFillColor DESIGNABLE
true)
public:
~Foo();
void setColor
(QColor p_color
);
};
and in the .cpp file, for example:
Code:
#include "foo.h"
#include "ui_foo.h"
// handle QGradient metatype registration for our property
qRegisterMetaType<QLinearGradient>("QLinearGradient");
ui->setupUi(this);
}
Foo:~Foo() {
delete ui;
}
}
void Foo
::setColor(QColor p_color
) { qDebug() << "Got Color Change";
}
}
qDebug() << "Got new QGradient";
}
And, the qss (loaded from a file):
Code:
Foo {
qproperty-color: rgb(77, 154, 205);
qproperty-fillColor: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(77, 154, 205, 255), stop:1 rgba(255, 255, 255, 175));
}
Which results in a debugging message showing setColor() is called, but no message indicates setFillColor() was called. EDIT: I forgot to note, the read method -does- get called.
Is there something I'm failing to do to pass a QLinearGradient properly? I know I can pass the two colors in the gradient without issue, as individual properties, but I want the QSS to be able to control the spread, etc. without a lot of qproperty- settings. (And all of the requisite code).
Thanks!