Unsolved Custom widget stylesheet
-
I have my own QWidget based class
class LFVResizeBar : public QWidget { Q_OBJECT public: LFVResizeBar(QWidget *parent = 0); ~LFVResizeBar(); protected: void resizeEvent(QResizeEvent *event); void paintEvent(QPaintEvent *event); private: Ui::LFVResizeBar ui; };
and in constructor I'm setting
setStyleSheet("QWidget#LFWindowTitlteBar{background: black;}"); // object name is LFWindowTitlteBar
but without effect :( what's the problem?
-
Hi! Are you sure you set the object name? What does
qDebug() << objectName();
print when called fromLFWindowTitlteBar
? Where is thesetObjectName("LFWindowTitlteBar");
call? -
@Alatriste said:
// object name is
I told you in my code..object name is LFWindowTitlteBar
setStyleSheet("QWidget#LFWindowTitlteBar{background: black;}"); // object name is LFWindowTitlteBar
-
@Alatriste
Hello,
But where do you set the object name? Could you provide the class' constructor and this implementationLFVResizeBar::paintEvent(QPaintEvent *event)
as well?Kind regards.
-
If LFVResizeBar is the widget class you want to target, I would suggest changing your CSS to QWidget#LFVResizeBar, and in the constructor of the LFVResizeBar or somewhere you need to set the name of the object to "LFVResizeBar" so the CSS will match it as Wieland indicated.
It may work if the name doesn't match the class, but just for consistency and maintainability sake I would have them be the same.