qt - Custom Widget stylesheet is not set with property -


I have a custom widget in the project and I'm trying to change the background color and label color with the click event. The color of the background varies but the label does not change color ... hopefully someone can help me find out where I am ... # #include "myframe.h" Main window: main window ( QWidget * Guardian): QMainWindow (parent), UI (new UI :: mainwondo) {UI-> SetupUi (this); MyFrame * frames = new MyFrame (this); UI- & gt; GridLayout_2- & gt; AddWidget (frame); SetStyleSheet ("MyFrame {pressed \" true \ "] {background-color: red;}" "MyFrame {background-color: yellow;}" "MyFrame QLabel {color: black; font: bold 12px;}" [Pressed = \ "true \"] QLabel {color: white;} "); } Main Window :: ~ MAIN WANDO () {DELETE UI; }

My custom widget / header file

  #ifndef MYFRAME_H #define MYFRAME_H #include & lt; QFrame & gt; # Include & lt; QGridLayout & gt; # Include & lt; QLabel & gt; # Include & lt; QDebug & gt; Class MyFrame: Public QFrame {Q_OBJECT Q_PROPERTY (pressed BEL pressed READ pressed pressed) QGridLayout * Layout; QLabel * name; Public: Clear MyFrame (QWidget * parent = 0); Hint: Public slots: Hair pressed (); Zero set (bull); Protected: pressed bool m; Zero mouseprint event (QMouseEvent * event); Zero mouseReleaseEvent (QMouseEvent * event); }; #endif // MYFRAME_H  

// source file

  #include "myframe.h" MyFrame :: MyFrame (QWidget * parent): QFrame (parent ) {Mpressed = false; Layout = New QGridLayout (this); SetLayout (layout); Name = new QLabel ("button"); Layout & gt; AddWidget (name); } BullMeframe :: Pressed () (qDebug)  unpolish (this); style () -> polish (this);} zero MyFrame :: mouseReleaseEvent (QMouseEvent * event) {qDebug ()  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -