I am new to QT and C++ and i have legacy qt-c++ code here which i cant get to work. Probably its something about the lifetime of the calling objects but hey, but please tell me what i am missing.
In a QT .ui i have various Frames and Widgets containing Frames and Widgets containing a QVBoxLayout
which we shall call "myLayout"
On click in the .ui file i use
myWidget = new mywidget(some params);
myLayout->addWidget(myWidget);
where myWidget is declared as mywidget *myWidget;
in the header file
myWidget is a QWidget
which internally adds a QVBoxLayout
to itself and adds a QGraphicsView
. Using the MouseReleaseEvent
i emit a signal from the QWidget.
now when i try to connect the signal slot (which i do in cpp file from the ui)
connect(myWidget, SIGNAL(mySignal(QString)), this, SLOT(mySlot(QString)));
the signals never catch the slot. the slot is public, the signal isnt.
What did i do wrong? Can somebody help. Feel free to ask further questions since i dont really know whats important in c++ questions;)
edit:
the signal gets emitted by QGraphicsObjects
which themselfs connect to a slot in the QGraphicsView
. This Slot is called and debuggable. at the end of the Routine an emit mySignal("...");
is called.
Maybe you forgot to add Q_OBJECT
macro in your widget declaration. Qt documentation: http://doc.qt.io/qt-5/qobject.html#Q_OBJECT