Q_UNUSED ( ) 的作用

今天看qcustom源码 Q_UNUSED(details) 看到这一句
/*!
This event gets called when the user presses a mouse button while the cursor is over the
layerable. Whether a cursor is over the layerable is decided by a preceding call to \ref
selectTest.

The current pixel position of the cursor on the QCustomPlot widget is accessible via \c
event->pos(). The parameter \a details contains layerable-specific details about the hit, which
were generated in the previous call to \ref selectTest. For example, One-dimensional plottables
like \ref QCPGraph or \ref QCPBars convey the clicked data point in the \a details parameter, as
\ref QCPDataSelection packed as QVariant. Multi-part objects convey the specific \c
SelectablePart that was hit (e.g. \ref QCPAxis::SelectablePart in the case of axes).

QCustomPlot uses an event propagation system that works the same as Qt’s system. If your
layerable doesn’t reimplement the \ref mousePressEvent or explicitly calls \c event->ignore() in
its reimplementation, the event will be propagated to the next layerable in the stacking order.

Once a layerable has accepted the \ref mousePressEvent, it is considered the mouse grabber and
will receive all following calls to \ref mouseMoveEvent or \ref mouseReleaseEvent for this mouse
interaction (a “mouse interaction” in this context ends with the release).

The default implementation does nothing except explicitly ignoring the event with \c
event->ignore().

\see mouseMoveEvent, mouseReleaseEvent, mouseDoubleClickEvent, wheelEvent
*/

void QCPLayerable::mousePressEvent(QMouseEvent *event, const 
QVariant &details)
{
  Q_UNUSED(details)
  event->ignore();
}

Q_UNUSED() 没有实质性的作用,用来避免编译器警告
比如下图(qt中不用的函数 或变量 也会有个警告的)
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

七 六 伍

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值