Reputation: 2973
In my statusbar, I have added one QLabel
inside which I am displaying some message. Now what I want is when I click on that QLabel
(present inside the QStatusBar
), the message should disappear..
I have added the label inside statusbar as follows:
QLabel *cpyrightlbl= new QLabel();
ui.statusBar->addWidget(cpyrightlbl);
cpyrightlbl->setText("Demo Message");
cpyrightlbl->setStyleSheet("border: 3px");
cpyrightlbl->setFixedWidth(frameGeometry().width());
cpyrightlbl->show();
Upvotes: 0
Views: 324
Reputation: 4110
You should create your own class which derives from QLabel
and then reimplement the function QLabel::mousePressEvent ( QMouseEvent * ev )
.
void CMyLabel::mousePressEvent( QMouseEvent * ev )
{
if( ev->button() == Qt::LeftButton )
{
this->clear();
// or
// this->setText( "" );
}
QLabel::mousePressEvent( ev );
}
Upvotes: 1