Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QObject * QObject::sender (  )  const [protected, inherited]

Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. The pointer is valid only during the execution of the slot that calls this function.

The pointer returned by this function becomes invalid if the sender is destroyed, or if the slot is disconnected from the sender's signal.

Warning:
This function violates the object-oriented principle of modularity. However, getting access to the sender might be useful when many signals are connected to a single slot.
See also:
QSignalMapper

Definition at line 2220 of file qobject.cpp.

Referenced by Calculator::additiveOperatorClicked(), GLWidget::animate(), MainWindow::applyFilter(), Q3ButtonGroup::buttonClicked(), Q3ButtonGroup::buttonDestroyed(), Q3ButtonGroup::buttonPressed(), Q3ButtonGroup::buttonReleased(), MainWindow::changeBrush(), MainWindow::changeStyle(), Q3ActionGroup::childActivated(), Q3ActionGroup::childDestroyed(), Q3ActionGroup::childToggled(), StarDelegate::commitAndCloseEditor(), Calculator::digitClicked(), ImageDelegate::emitCommitData(), MainWindow::insertShape(), MainWindow::itemColorChanged(), MainWindow::lineColorChanged(), QSignalMapper::map(), Q3MainWindow::menuAboutToShow(), Calculator::multiplicativeOperatorClicked(), Q3ActionGroup::objectDestroyed(), Q3Action::objectDestroyed(), Q3Action::showStatusText(), MainWindow::textColorChanged(), and Calculator::unaryOperatorClicked().

{
    Q_D(const QObject);

    QMutexLocker(&d->threadData->mutex);
    if (!d->currentSender)
        return 0;

    // Return 0 if d->currentSender isn't in d->senders
    bool found = false;
    for (int i = 0; !found && i < d->senders.count(); ++i)
        found = (d->senders.at(i).sender == d->currentSender->sender);
    if (!found)
        return 0;
    return d->currentSender->sender;
}


Generated by  Doxygen 1.6.0   Back to index