Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Signal / Slot problem
Forum Updated to NodeBB v4.3 + New Features

Signal / Slot problem

Scheduled Pinned Locked Moved Unsolved Game Development
5 Posts 3 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DPixel
    wrote on last edited by aha_1980
    #1

    Hello everyone,

    I don't usualy come ask for help in forum but... Well I don't understand what I've done wrong and I'm out of idea. So here we go :
    I have two class and they have thoses problematics elements :

    class BridgeWin : public QDialog
    [...]
    public slots:
        void receiveInPos(int x, int y);
        void receiveOutPos(int x, int y);
    [...]
    
    class GraphicsView : public QGraphicsView
    [...]
    signals:
        void sendInPos(int x, int y);
        void sendOutPos(int x, int y);
    [...]
    

    They are each only used once, here all the instance :

    [...]
    void BridgeWin::receiveInPos(int x, int y)
    {
        qDebug() << "received";
        int cellRow = selectionCellInView->currentIndex().row();
        int bridgeRow = bridgeView->currentIndex().row();
        if(cellRow>=0 && bridgeRow>=0)
        {
            Cell *c = data->rowToCell(cellRow);
            c->bridgeList.at(bridgeRow)->setPointA(QPoint(x,y));
        }
    }
    void BridgeWin::receiveOutPos(int x, int y)
    {
        qDebug() << "received";
        int cellRow = selectionCellInView->currentIndex().row();
        int bridgeRow = bridgeView->currentIndex().row();
        if(cellRow>=0 && bridgeRow>=0)
        {
            Cell *c = data->rowToCell(cellRow);
            c->bridgeList.at(bridgeRow)->setPointB(QPoint(x,y));
            c->bridgeList.at(bridgeRow)->setID_b(data->cellRowToId(cellRow));
        }
    }
    [...]
    
    [...]
    void GraphicsView::ApplyBridgeTile()
    {
        Cell *c;
        if(cellIdBridgeIn >= 0)
        {
            c = data->idToCell(cellIdBridgeIn);
            if(pos.x() >= 0 && pos.y() >= 0 && pos.x() < c->tx && pos.y() < c->ty)
            {
                qDebug() << "sending : " << pos.x() << pos.y();
                emit sendInPos(pos.x(),pos.y());
                qDebug() << "send";
            }
        }
        else
        {
            c = data->idToCell(cellIdBridgeOut);
            if(pos.x() >= 0 && pos.y() >= 0 && pos.x() < c->tx && pos.y() < c->ty)
            {
                qDebug() << "sending : " << pos.x() << pos.y();
                emit sendOutPos(pos.x(),pos.y());
                qDebug() << "send";
            }
        }
    }
    [...]
    

    So the problem is, despite the fact that I connected them :

    [...]
    connect(view, SIGNAL(sendInPos(int, int)), menuBar->bridgeWin, SLOT(receiveInPos(int, int)));
    connect(view, SIGNAL(sendOutPos(int, int)), menuBar->bridgeWin, SLOT(receiveOutPos(int, int)));
    [...]
    

    I allways get in the console (with the value I intended for x and y) :
    sending : x y
    send

    It never reach the "received" pole. What did I miss? Why all my others signals and slots are working just fine and not thoses four?

    Thanks you for you're intention and sorry for my poor english, it's not my native language.

    1 Reply Last reply
    0
    • Pradeep KumarP Offline
      Pradeep KumarP Offline
      Pradeep Kumar
      wrote on last edited by
      #2

      Hi @DPixel ,

      Have u used Q_OBJECT macro in the class , just to ensure on the safer side. ?

      Thanks,

      Pradeep Kumar
      Qt,QML Developer

      1 Reply Last reply
      4
      • D Offline
        D Offline
        DPixel
        wrote on last edited by DPixel
        #3

        Yes, and in fact the class

        class BridgeWin : public QDialog
        
        class GraphicsView : public QGraphicsView
        

        (and this one that have hold the connection above)

        class MainWindow : public QMainWindow
        

        are all related to the problem in some point and have a lot of signal and slots working just fine. I bet it doesn't work because of something stupid I shouldn't have done but I can't find what...

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DPixel
          wrote on last edited by DPixel
          #4

          Nevermind, it was indeed stupid. In fact I have 3 instance of "GraphicsView" :
          one for editing map.
          two for creating path beatween map.

          So I rewired it and now it works.

          Sorry for wasting your time and thanks trying to help me.

          Pablo J. RoginaP 1 Reply Last reply
          0
          • D DPixel

            Nevermind, it was indeed stupid. In fact I have 3 instance of "GraphicsView" :
            one for editing map.
            two for creating path beatween map.

            So I rewired it and now it works.

            Sorry for wasting your time and thanks trying to help me.

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @DPixel please don't forget to mark your post as solved! Thanks

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved