Changeset - 72080817dbc5
[Not reviewed]
default
0 1 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2016-02-28 08:06:53
hy@ozderya.net
fix tooltip crash on toolbutton without default action (for ex; commandwidget remove button)
1 file changed with 11 insertions and 3 deletions:
0 comments (0 inline, 0 general)
tooltipfilter.cpp
Show inline comments
 
@@ -29,21 +29,29 @@ bool ToolTipFilter::eventFilter(QObject 
 
{
 
    if (ev->type() == QEvent::ToolTip && obj->inherits("QToolButton"))
 
    {
 
        // prepare tooltip message
 
        QToolButton* toolButton = (QToolButton*) obj;
 
        QAction* action = toolButton->defaultAction();
 
        QString toolTip = action->toolTip();
 

	
 
        if (toolTip.isEmpty()) return false;
 

	
 
        QString toolTip;
 
        if (action != NULL)
 
        {
 
            toolTip = action->toolTip();
 
        QKeySequence keys = action->shortcut();
 
        if (!keys.isEmpty())
 
        {
 
            toolTip += QString(" <b>[") + keys.toString() + "]</b>";
 
        }
 
        }
 
        else
 
        {
 
            toolTip = toolButton->toolTip();
 
        }
 

	
 
        if (toolTip.isEmpty()) return false;
 

	
 
        // show tooltip message
 
        QHelpEvent *helpEvent = static_cast<QHelpEvent *>(ev);
 
        QToolTip::showText(helpEvent->globalPos(), toolTip);
 
        return true;
 
    }
0 comments (0 inline, 0 general)