Results 1 to 7 of 7

Thread: Connect call causes a SEGFAULT

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2015
    Posts
    50
    Qt products
    Qt5
    Platforms
    Unix/X11
    Thanks
    8

    Default Connect call causes a SEGFAULT

    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
    Qt Code:
    1. void CMainWindow::createSignalSlots() {
    2. connect(m_pGraphWidget, SIGNAL(createObj(QGraphicsItem *)), m_pPhysObjNavigator, SLOT(onCreateObj(QGraphicsItem *)));
    3. }
    To copy to clipboard, switch view to plain text mode 

    m_pGraphWidget is defined by the class definition like so:
    Qt Code:
    1. class GraphWidget : public QGraphicsView {
    2. Q_OBJECT
    3. signals:
    4. void createObj(QGraphicsItem *);
    5. void removeObj(QGraphicsItem *);
    6. void modifyObj(QGraphicsItem *);
    To copy to clipboard, switch view to plain text mode 

    m_pPhysObjNavigator is defined by the class definition like so:
    Qt Code:
    1. class PhysObjectNavigator : public QTreeView {
    2. public:
    3. PhysObjectNavigator(QWidget * = NULL);
    4.  
    5. public slots:
    6. void onCreateObj(QGraphicsItem *);
    To copy to clipboard, switch view to plain text mode 

    Code in GraphWidget that makes the emit call is here:
    Qt Code:
    1. void GraphWidget::createCartesianGraph() {
    2.  
    3. // Create the object
    4. m_pCartGraph = new CartesianGraph(this);
    5. m_pCartGraph -> setPos(0, 0);
    6. m_pScene -> addItem(m_pCartGraph);
    7. emit createObj(m_pCartGraph);
    8. }
    To copy to clipboard, switch view to plain text mode 

    Code that is supposed to receive the signal is:
    Qt Code:
    1. void PhysObjectNavigator::onCreateObj(QGraphicsItem *pObj) {
    2. if (pObj) {
    3. switch (pObj -> type()) {
    4. case PhysBaseItem::VectorType:
    5. break;
    6. case PhysBaseItem::ParticleType:
    7. break;
    8. case PhysBaseItem::CartesianGraphType:
    9. break;
    10. default:
    11. break;
    12. }
    13. }
    14. }
    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.
    Last edited by Caolan O'Domhnaill; 24th October 2015 at 01:43. Reason: I made a lame rookie mistake -- repurposing since I cannot delete it

Similar Threads

  1. Replies: 2
    Last Post: 26th August 2011, 08:51
  2. Slot function not being executed in connect
    By Leirbag89 in forum Newbie
    Replies: 7
    Last Post: 19th May 2011, 19:53
  3. Replies: 3
    Last Post: 7th April 2011, 11:09
  4. Replies: 1
    Last Post: 10th December 2010, 15:59
  5. QThread slot executed in GUI thread
    By tnyblom in forum Qt Programming
    Replies: 13
    Last Post: 25th May 2010, 07:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.