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 15 insertions and 7 deletions:
0 comments (0 inline, 0 general)
tooltipfilter.cpp
Show inline comments
 
@@ -32,16 +32,24 @@ bool ToolTipFilter::eventFilter(QObject 
 
        // prepare tooltip message
 
        QToolButton* toolButton = (QToolButton*) obj;
 
        QAction* action = toolButton->defaultAction();
 
        QString toolTip = action->toolTip();
 

	
 
        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;
 

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

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