Frage

I have a signal which its declaration is:

void removed(int sPI, int sWID , int ePI, int eWID);

I want to connect it to a slots twice, first needs sPI and sWID arguments and other slot needs ePI and eWID. The slot declaration is:

void disconnect(int i, int wID = 0);

( I want when removed() emits, disconnect(sPI, sWID) and also disconnect(ePI, eWID) )

Please help me in writing QObject::connect() statement. Thanks.

War es hilfreich?

Lösung

For the first, "disconnect(sPI, sWID)", just do:

connect(x, SIGNAL(removed(int,int,int,int)), y, SLOT(disconnect(int,int)));

The third and forth argument will just be ignored and disconnect will be called with the first two.

The second connect, "disconnect(ePI, eWID)" is not possible. You'd need an intermediate slot connected to removed():

Declaration:

Q_SLOTS:
    void somethingRemoved(int, int, int, int);

Definition:

void Foobar::somethingRemoved(int sPI, int sWID, int ePI, int eWID) {
    disconnect(sPI, sWID);
    disconnect(ePI, eWID);
}

Connect:

connect(x, SIGNAL(removed(int,int,int,int)), foobar, SLOT(somethingRemoved(int,int,int,int)));
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top