QT,QAction中的ToolTip

QAction ( const QString & text, QObject * parent )

QAction ( const QIcon & icon, const QString & text, QObject * parent )

QAction的两个构造函数中的text参数,文档的描述是:

The action uses a stripped version of text (e.g. "&Menu Option..." becomes "Menu Option") as descriptive text for tool buttons. You can override this by setting a specific description with setText(). The same text will be used for tooltips unless you specify a different text using setToolTip().

这个text会作为默认的toolTip提示,如果你另外想指定toolTip请使用setToolTip().

 

QToolButton *pTb = new QToolButton();

QAction *pAct = new QAction("默认提示",this);

pTb ->setDefaultAction(act);

设置QToolButton的默认提示。如果不想有提示,text设为"" 空字符串即可。

原文地址:https://www.cnblogs.com/yuzhould/p/4454275.html