Solved problem setting a stylesheet
-
Hi All,
I want to pass the following push-button style settings into the
setStyleSheet
, and to reuse a few times:background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 : 1, stop : 0.0 #ffd9aa, stop : 0.5 #ffbb6e, stop : 0.55 #feae42, stop : 1.0 #fedb74);
But I can't store the above settings as
QString
. Can you suggest a workaround? -
@viniltc said in problem setting a stylesheet:
But I can't store the above settings as QString
Why not?
-
@jsulm Hi
I tried this:
QString StyleSetting("background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 : 1, stop : 0.0 #ffd9aa, stop : 0.5 #ffbb6e, stop : 0.55 #feae42, stop : 1.0 #fedb74)");
it gives me errors:
programkey.cpp:489:22: error: expected expression programkey.cpp:490:24: error: use of undeclared identifier 'stop'
-
@viniltc You can't split a string across several lines like this in C++
Corrected version:QString StyleSetting("background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 : 1, stop : 0.0 #ffd9aa," "stop : 0.5 #ffbb6e, stop : 0.55 #feae42, stop : 1.0 #fedb74)");
-
@viniltc
solved it!
Sorry , my bad! that string should be in one line!.QString StyleSetting("background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 : 1, stop : 0.0 #ffd9aa, stop : 0.5 #ffbb6e, stop : 0.55 #feae42, stop : 1.0 #fedb74)");