qt - Handling mouseevent in QStatusBar -
In my status prompt, I added a The added status is added to the following: QLabel inside which I am displaying some message . Now what do I want to do when I click on that code in
QLabel (
QStatusBar ), the message should be missing.
QLabel * cpyrightlbl = new QLabel (); Ui.statusBar-> AddWidget (cpyrightlbl); Cpyrightlbl- & gt; Set text ("demo message"); Cpyrightlbl- & gt; Set stylesheet ("border: 3px"); Cpyrightlbl- & gt; SetFixedWidth (.frameGameometry () width ()); Cpyrightlbl- & gt; Show (); You should create your own category from
QLabel And then the function
QLabel :: mousePressEvent (QMouseEvent * ev) .
Repeat the zero CMyLabel :: mousePressEvent (QMouseEvent * ev) function {if (& gt; Button) == QT :: LeftButton} {This-> clear (); // or // it- & gt; Set text (""); } QLabel :: Mousepress Event (Eve); }
Comments
Post a Comment