PDA

View Full Version : trouble with QObject::connect...



kennethadammiller
9th July 2010, 05:38
With this code below:

QGraphicsScene scene;
QPen *pen;
QBrush *brush;
QGraphicsView view(&scene);
QSpinBox *spinbox1 = w.findChild<QSpinBox *>("spinBox_2");
QObject::connect(spinbox1, SIGNAL(valueChanged(int)), &scene, SLOT(
addEllipse(
spinbox1->value(), spinbox2->value(), spinbox3->value(), spinbox4->value(), pen , brush )));

Please tell me why this error is occurring?

Starting C:\Users\Adam\QTProjects\BasicShooter\debug\BasicS hooter.exe...
Object::connect: No such slot QGraphicsScene::addEllipse( spinbox1->value(), spinbox2->value(), spinbox3->value(), spinbox4->value(), pen , brush ) in main.cpp:44
Object::connect: (sender name: 'spinBox_2')
C:\Users\Adam\QTProjects\BasicShooter\debug\BasicS hooter.exe exited with code 0

kennethadammiller
9th July 2010, 05:41
damn. this is the second time i've done this tonight. alright, i've found the answer to this one too. lol found it at:
http://www.qtcentre.org/threads/24912-Help-QObject-connect

kennethadammiller
9th July 2010, 07:14
ok... so this one isn't actually solved at all. I still need help!

will someone explain to me how I will get the values from the other spinboxes into the addEllipse function whenever the spinbox is clicked? because it looks to me like you can't specify actual arguments in the QObject::connect function for a SLOT, just what type they are... how does QObject know what to send where when there are multiple parameters?

ChrisW67
9th July 2010, 07:31
First problem: QGraphicsScene does not have a slot called addEllipse(), that's a standard member function.
Second problem: You specify the types of arguments, for both SIGNAL and SLOT, in the connect, not the actual values. Connect is establishing a communication path not actually placing the call.

You need to write slot to receive the valueChanged(int) signal and connect to that. The code of that slot can then fetch the spin box value and do whatever it likes with it, including calling addElipse().