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() {
}
void CMainWindow::createSignalSlots() {
connect(m_pGraphWidget, SIGNAL(createObj(QGraphicsItem *)), m_pPhysObjNavigator, SLOT(onCreateObj(QGraphicsItem *)));
}
To copy to clipboard, switch view to plain text mode
m_pGraphWidget is defined by the class definition like so:
Q_OBJECT
signals:
class GraphWidget : public QGraphicsView {
Q_OBJECT
signals:
void createObj(QGraphicsItem *);
void removeObj(QGraphicsItem *);
void modifyObj(QGraphicsItem *);
To copy to clipboard, switch view to plain text mode
m_pPhysObjNavigator is defined by the class definition like so:
class PhysObjectNavigator
: public QTreeView {public:
PhysObjectNavigator
(QWidget * = NULL);
public slots:
class PhysObjectNavigator : public QTreeView {
public:
PhysObjectNavigator(QWidget * = NULL);
public slots:
void onCreateObj(QGraphicsItem *);
To copy to clipboard, switch view to plain text mode
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);
}
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);
}
To copy to clipboard, switch view to plain text mode
Code that is supposed to receive the signal is:
if (pObj) {
switch (pObj -> type()) {
case PhysBaseItem::VectorType:
break;
case PhysBaseItem::ParticleType:
break;
case PhysBaseItem::CartesianGraphType:
break;
default:
break;
}
}
}
void PhysObjectNavigator::onCreateObj(QGraphicsItem *pObj) {
if (pObj) {
switch (pObj -> type()) {
case PhysBaseItem::VectorType:
break;
case PhysBaseItem::ParticleType:
break;
case PhysBaseItem::CartesianGraphType:
break;
default:
break;
}
}
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks