Hello, I would like to create a SLOT that establish some connections between classes. Something like this:

Qt Code:
  1. void MainWindow::onDocumentDockletUndocked( bool isFloating )
  2. {
  3. if(isFloating) {
  4. foreach(MultiEditor * me, mEditorList) {
  5. connect(me, SIGNAL(currentDocumentChanged(Document*)),
  6. mDocumentsDocklet, SLOT(setCurrent(Document*)));
  7. }
  8. } else {
  9. foreach(MultiEditor * me, mEditorList) {
  10. disconnect(me, SIGNAL(currentDocumentChanged(Document*)),
  11. mDocumentsDocklet, SLOT(setCurrent(Document*)));
  12. }
  13. }
  14. }
To copy to clipboard, switch view to plain text mode 

This specific example isn't working (though the same works perfectly in a different context).
So I was wondering: can I established or remove connections on the fly as above?