QWidget *widget = QApplication::widgetAt(event->pos());
To copy to clipboard, switch view to plain text mode
This will not work. QApplication::widgetAt() expects a global screen position and event->pos() gives position of the mouse cursor, relative to the widget that received the event
With this method, prompts("over pushbutton") in the status bar, but the pushbutton isn't display in the window.
You code should look like this
if(obj == ui->pushButton)
{
if(event
->type
() == QEvent::Enter) {
ui->statusbar->setToolTip(tr("over pushbutton"));
}
else if(event
->type
() == QEvent::Leave) ui->statusbar->setToolTip(tr(""));
}
else
{
ui->statusbar->setToolTip(tr(""));
}
return QWidget::eventFilter(obj,event
);
if(obj == ui->pushButton)
{
if(event->type() == QEvent::Enter)
{
ui->statusbar->setToolTip(tr("over pushbutton"));
}
else if(event->type() == QEvent::Leave)
ui->statusbar->setToolTip(tr(""));
}
else
{
ui->statusbar->setToolTip(tr(""));
}
return QWidget::eventFilter(obj,event);
To copy to clipboard, switch view to plain text mode
Bookmarks