samedi 3 juin 2017

Send sender as SLOT argument

I've got problem with signal/slot mechanism in Qt. I would like to write code like this.

void AddDialog::connectLineEdits()
{
    foreach (const QLineEdit* edt, listEdits) {
        // When text in QLineEdit is changed, it must remove it's QGraphicsEffect
        connect(edt, SIGNAL( textChanged(const QString &) ), SLOT( removeEffect() );
    }
}

The QGraphicsEffect set:

 void AddDialog::addEffect(QWidget *widget)
{
    QGraphicsColorizeEffect *effect = new QGraphicsColorizeEffect(widget);
    effect->setColor(QColor(250, 0, 0));
    widget->setGraphicsEffect(effect);
}

Are there any ways to do that, except creating class for derived from QLineEdit?

Aucun commentaire:

Enregistrer un commentaire