Ejemplo n.º 1
0
/*! \reimp */
bool QPushButton::hitButton(const QPoint &pos) const
{
    QStyleOptionButton opt;
    initStyleOption(&opt);
    if (qt_mac_buttonIsRenderedFlat(this, &opt))
        return QAbstractButton::hitButton(pos);

    // Now that we know we are using the native style, let's proceed.
    Q_D(const QPushButton);
    QPushButtonPrivate *nonConst = const_cast<QPushButtonPrivate *>(d);
    // In OSX buttons are round, which causes the hit method to be special.
    // We cannot simply relay on detecting if something is inside the rect or not,
    // we need to check if it is inside the "rounded area" or not. A point might
    // be inside the rect but not inside the rounded area.
    // Notice this method is only reimplemented for OSX.
    return nonConst->hitButton(pos);
}
/*! \reimp */
bool QPushButton::hitButton(const QPoint &pos) const
{
    // This is only required if we are using the native style, so check that first.
        QMacStyle *macStyle = qobject_cast<QMacStyle *>(style());
    // If this is a flat button we just bail out.
    if(isFlat() || (0 == macStyle))
        return QAbstractButton::hitButton(pos);
    // Now that we know we are using the native style, let's proceed.
    Q_D(const QPushButton);
    QPushButtonPrivate *nonConst = const_cast<QPushButtonPrivate *>(d);
    // In OSX buttons are round, which causes the hit method to be special.
    // We cannot simply relay on detecting if something is inside the rect or not,
    // we need to check if it is inside the "rounded area" or not. A point might
    // be inside the rect but not inside the rounded area.
    // Notice this method is only reimplemented for OSX.
    return nonConst->hitButton(pos);
}