Caolan O'Domhnaill
24th October 2015, 00:47
Hey all,
The code compiles and links w/o issue.
Here's where I make the connect() call in my MainWindow class. It happens in the initialisation code of my Main Window. I have verified that the source and target of signal and slot respectively are valid addresses and being created.
This yields the segfault
void CMainWindow::createSignalSlots() {
connect(m_pGraphWidget, SIGNAL(createObj(QGraphicsItem *)), m_pPhysObjNavigator, SLOT(onCreateObj(QGraphicsItem *)));
}
m_pGraphWidget is defined by the class definition like so:
class GraphWidget : public QGraphicsView {
Q_OBJECT
signals:
void createObj(QGraphicsItem *);
void removeObj(QGraphicsItem *);
void modifyObj(QGraphicsItem *);
m_pPhysObjNavigator is defined by the class definition like so:
class PhysObjectNavigator : public QTreeView {
public:
PhysObjectNavigator(QWidget * = NULL);
public slots:
void onCreateObj(QGraphicsItem *);
Code in GraphWidget that makes the emit call is here:
void GraphWidget::createCartesianGraph() {
// Create the object
m_pCartGraph = new CartesianGraph(this);
m_pCartGraph -> setPos(0, 0);
m_pScene -> addItem(m_pCartGraph);
emit createObj(m_pCartGraph);
}
Code that is supposed to receive the signal is:
void PhysObjectNavigator::onCreateObj(QGraphicsItem *pObj) {
if (pObj) {
switch (pObj -> type()) {
case PhysBaseItem::VectorType:
break;
case PhysBaseItem::ParticleType:
break;
case PhysBaseItem::CartesianGraphType:
break;
default:
break;
}
}
}
I thought it might be because PhysObjectNavigator does not have the Q_OBJECT macro defined in it but when I do put it there I get the error:
undefined reference to 'vtable for PhysObjectNavigator'
However it is derived from QTreeView which already includes Q_OBJECT so it shouldn't be a big deal.
Any ideas? It all seems set up and ready to go.
The code compiles and links w/o issue.
Here's where I make the connect() call in my MainWindow class. It happens in the initialisation code of my Main Window. I have verified that the source and target of signal and slot respectively are valid addresses and being created.
This yields the segfault
void CMainWindow::createSignalSlots() {
connect(m_pGraphWidget, SIGNAL(createObj(QGraphicsItem *)), m_pPhysObjNavigator, SLOT(onCreateObj(QGraphicsItem *)));
}
m_pGraphWidget is defined by the class definition like so:
class GraphWidget : public QGraphicsView {
Q_OBJECT
signals:
void createObj(QGraphicsItem *);
void removeObj(QGraphicsItem *);
void modifyObj(QGraphicsItem *);
m_pPhysObjNavigator is defined by the class definition like so:
class PhysObjectNavigator : public QTreeView {
public:
PhysObjectNavigator(QWidget * = NULL);
public slots:
void onCreateObj(QGraphicsItem *);
Code in GraphWidget that makes the emit call is here:
void GraphWidget::createCartesianGraph() {
// Create the object
m_pCartGraph = new CartesianGraph(this);
m_pCartGraph -> setPos(0, 0);
m_pScene -> addItem(m_pCartGraph);
emit createObj(m_pCartGraph);
}
Code that is supposed to receive the signal is:
void PhysObjectNavigator::onCreateObj(QGraphicsItem *pObj) {
if (pObj) {
switch (pObj -> type()) {
case PhysBaseItem::VectorType:
break;
case PhysBaseItem::ParticleType:
break;
case PhysBaseItem::CartesianGraphType:
break;
default:
break;
}
}
}
I thought it might be because PhysObjectNavigator does not have the Q_OBJECT macro defined in it but when I do put it there I get the error:
undefined reference to 'vtable for PhysObjectNavigator'
However it is derived from QTreeView which already includes Q_OBJECT so it shouldn't be a big deal.
Any ideas? It all seems set up and ready to go.