Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Forward Declaration Error on overriding
QtWS25 Last Chance

Forward Declaration Error on overriding

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 780 Views
  • 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.
  • faiszalkhanF Offline
    faiszalkhanF Offline
    faiszalkhan
    wrote on last edited by
    #1

    I have made a class Canvas which inherits class QGraphicsScene.

    class Canvas : public QGraphicsScene
    {
    .....
    }

    I have overriden the function mousePressEvent with the following.

    /* This overridden is used to emit the signal to draw the state */
    void Canvas::mousePressEvent(QGraphicsSceneMouseEvent *gevent)
    {
    //This is not working
    // gevent->pos();
    qDebug("The value of the input event is \n");
    // qDebug()<<gevent;
    qDebug("Mouse has been pressed");
    emit(makestate(gevent)); //emit the signal here
    }

    My basic requirement is to get the pos() of the mouse clicked. The problem is that in the below function I cannot access gevent. The reported errors are as follows:
    error: member access into incomplete type 'QGraphicsSceneMouseEvent'
    note: forward declaration of 'QGraphicsSceneMouseEvent'
    class QGraphicsSceneMouseEvent;

    Please help!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You are missing #include <QGraphicsSceneMouseEvent> in the file where you implement the method.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • faiszalkhanF Offline
        faiszalkhanF Offline
        faiszalkhan
        wrote on last edited by
        #3

        Thanks for your help!

        1 Reply Last reply
        1

        • Login

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