0xl33t
23rd July 2009, 22:47
Hey, how do you connect a signal from a child widget with a slot from the parent widget?
1) I have a MainWindow, and i want to connect the newAction (QAction)
2) the central widget of my main window is a stackedWidget which contains the child widget i want to connect
3) the child widget is a customWidget with a public slot, called foo()
See the attached image...
i tried with this from stackedWidget, which is between(child & parent) mainwindow-customwidget:
connect(parentWidget()->newAction, SIGNAL(triggered()), customWidget, SLOT(foo()));
i get an error saying that QWidget doesn't have a member called newAction()....
So, in short how to connect a child's slot with a parent's signal?
thanks
1) I have a MainWindow, and i want to connect the newAction (QAction)
2) the central widget of my main window is a stackedWidget which contains the child widget i want to connect
3) the child widget is a customWidget with a public slot, called foo()
See the attached image...
i tried with this from stackedWidget, which is between(child & parent) mainwindow-customwidget:
connect(parentWidget()->newAction, SIGNAL(triggered()), customWidget, SLOT(foo()));
i get an error saying that QWidget doesn't have a member called newAction()....
So, in short how to connect a child's slot with a parent's signal?
thanks