I used this approach:
Q_PROPERTY( bool isTalking
READ isTalking
WRITE setIsTalking
DESGNABLE true
SCRIPTABLE true)
bool _isTalking;
public:
{
this->setObjectName("MyClass");
_watch->addPath("xxxx.css");
connect(_watch,
SIGNAL(fileChanged
(QString),
this,
SLOT(loadStyleSheet
(QString)));
}
~MyClass();
bool isTalking() const
{return _isTalking;}
void setIsTalking(bool newIsTalking)
{_isTalking = newIsTalking;}
public slots:
void loadStyleSheet(const QString& css)
{
| IODevice::Text))
{
this->setStyleSheet(csssss);
}
}
Q_PROPERTY( bool isTalking
READ isTalking
WRITE setIsTalking
DESGNABLE true
SCRIPTABLE true)
bool _isTalking;
QFileSystemWatcher* _watch
public:
MyClass(QWidget *parent ) :
QWidget(parent)
{
this->setObjectName("MyClass");
_watch->addPath("xxxx.css");
connect(_watch, SIGNAL(fileChanged(QString),
this,SLOT(loadStyleSheet(QString)));
}
~MyClass();
bool isTalking() const
{return _isTalking;}
void setIsTalking(bool newIsTalking)
{_isTalking = newIsTalking;}
public slots:
void loadStyleSheet(const QString& css)
{
QFile cssfile(css);
if(cssfile.open(QIODevice::ReadOnly
| IODevice::Text))
{
QTextStream in(&cssFile);
QString cssssss(in.readAll());
this->setStyleSheet(csssss);
}
}
To copy to clipboard, switch view to plain text mode
In the css:
MyClass{qproperty-isTalking: true;}
MyClass{qproperty-isTalking: true;}
To copy to clipboard, switch view to plain text mode
However - changing properties from css file should not be used for all purposes (at least >5 pr second). it will be slooow.
Bookmarks