Connecting a children widget with main widget
-
Children widget? What widget would that be?
What do you mean by "access"? Call them? Sure, if your "Children widget" has a reference to the mainwindow and the slots are active, you can call them. But I doubt that is what you are after.
If your "children widget" is the widget responsible for the drawing, you probably want to define the slot(s) on that widget directly. Then, you can connect the signal from your buttons (or button group) to that slot or those slots from the mainwidget's constructor.
-
Hi,
I am colloborating with blixs. Thanks for your answers, wanted to make it a bit clearer...This is in our ui_mainwindow.h
@ void setupUi(QMainWindow *MainWindow)
{...
actionLinea = new QAction(MainWindow);
...
centralWidget = new PanelDibujo(MainWindow);
...
QObject::connect(actionLinea, SIGNAL(hovered()), centralWidget, SLOT(linea()));
}@And should trigger in our childwidget paneldibujo.cpp
@void PanelDibujo::linea()
{
lineaMarked = true;
}@But nothing happens...
It works with SLOT-methods like hide() etc... -
[quote author="tekblom" date="1295269403"]No, it is not declared as a slot. You need to do that somewhere?[/quote]
Yes, you must add that in the class definition (usually in a .h file). See the "Signals & Slots":http://doc.qt.nokia.com/stable/signalsandslots.html docs for some examples. Unfortunately the docs say it not clear enough, that you must add the "public/protected/private slots" keywords.
-
Oh, yeah I found it now.
Object::connect: No such slot PanelDibujo::linea() in ./ui_mainwindow.h:109
Object::connect: (sender name: 'actionLinea')
Object::connect: (receiver name: 'centralWidget')I added in paneldibujo.h
@ public slots:
void linea();@and the error disappeared but still nothings happens. Use the same code as before...
But now...Wow it works ;)
Had to rebuild it some times!Thanks for the help!