PDA

View Full Version : signal slot connection



Big Duck
4th July 2006, 13:25
Hi,
I have an application that allows allows new widgets to be created, much like an MDI interface.
I make a new menu Action when I create a new widget so the user can raise() the selected widget from a Windows Menu.

I have trouble when the user clicks on one of the menu actions.



{
boardWindow->menuAction = new QAction(text, this);
menuWindow->addAction(boardWindow->menuAction) ;

connect(boardWindow->menuAction, SIGNAL(triggered()), this, SLOT(selectWindow(boardWindow->menuAction->text())));
}


void MainWindow::selectWindow(QString text)
{}


I want to do something like above, pass the text or the QAction that initiated the signal. So that I can determine which one it is and thus raise() the appropriate widget.

I keep the menu Actions in a vector of class


class BoardWindow // For a new board vector.
{
public:
QAction* menuAction;
boost::shared_ptr<MainBoard> mainBoard;
int identifier; // A unique id
};


Any ideas, there must be a way, probably very simple.
Thanks.

jpn
4th July 2006, 13:28
Try QSignalMapper (http://doc.trolltech.com/4.1/qsignalmapper).

Big Duck
4th July 2006, 13:31
Yeah :) just found it in some threads after I posted, should do the trick. thanks