QGraphicsView and QGraphicsScene signals and slots
Okay,
I am trying to get a class that inherits from QGraphicsView (ChartViewer) and a class that inherits from QGraphicsScene (ChartScene) to use signals and slots to work with another class that inherits from QWidget (ChartPage).
ChartPage works fine with signals and slots to other objects.
ChartViewer and ChartScene however, cannot seem to use signals and slots. When I put the Q_OBJECT part at the beginning of the class, the code doesn't even seem to run. When I remove the Q_OBJECT part but leave my signals and slots in, the code builds, but all of my connect functions return a "No such signal: SIGNAL_NAME in QGraphicsView" for any signal or slot for either the view or the scene.
Here's a sample of the output I get:
Code:
Object
::connect: No such
signal QGraphicsScene::focusPointChanged( int,
int )Object
::connect: No such
slot QGraphicsView::enableMouseTracking( bool )Object
::connect: No such
slot QGraphicsView::acknowledgePressed()Object
::connect: No such
slot QGraphicsView::setFollowOwnship( bool )Object
::connect: No such
slot QGraphicsView::addMarkpointAtOwnship()Object
::connect: No such
slot QGraphicsView::setMarkpointCursor()Object
::connect: No such
signal QGraphicsView::launchRouteDialog()Object::connect: (receiver name: 'ChartPage')
Object
::connect: No such
signal QGraphicsView::launchTargetDialog()Object::connect: (receiver name: 'ChartPage')
Object
::connect: No such
slot QGraphicsScene::updateTargetRouteIndex( short )Object::connect: (sender name: 'ChartPage')
So... can QGraphicsView and QGraphicsScene use signals and slots? If so... what's the trick to getting that to happen?
Re: QGraphicsView and QGraphicsScene signals and slots
Quote:
When I remove the Q_OBJECT part but leave my signals and slots in, the code builds, but all of my connect functions return a "No such signal: SIGNAL_NAME in QGraphicsView" for any signal or slot for either the view or the scene.
You cannot expect it to work without the Q_OBJECT macro:
Quote:
The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and slots or that uses other services provided by Qt's meta-object system.
Quote:
When I put the Q_OBJECT part at the beginning of the class, the code doesn't even seem to run
What do you mean by "code doesn't even seem to run" ? Can you post it ?
Re: QGraphicsView and QGraphicsScene signals and slots
AFAIR, you should connect to QGraphicsView::viewport() signals.
Re: QGraphicsView and QGraphicsScene signals and slots
Finally!
I couldn't post the code, so I started writing a little sample app, and much to my surprise, the sample app. was working!
So I took a look back at my original code, and it had the same stuff in it! I was very confused.
SOLUTION: The clean function wasn't cleaning my build folder. I had to go and manually clean it. And by clean I mean DELETE EVERYTHING THAT EVER EXISTED THAT EVEN REMOTELY MESSED WITH ME OR MY BEAUTIFUL CODE. Now it builds. Without issues. Thanks for your help everyone. Sorry I'm such a tard!