Results 1 to 4 of 4

Thread: trouble with QObject::connect...

  1. #1
    Join Date
    Jul 2010
    Posts
    18
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default trouble with QObject::connect...

    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

  2. #2
    Join Date
    Jul 2010
    Posts
    18
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: trouble with QObject::connect...

    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/2491...Object-connect

  3. #3
    Join Date
    Jul 2010
    Posts
    18
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: trouble with QObject::connect...

    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?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: trouble with QObject::connect...

    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().

Similar Threads

  1. [Help] QObject::connect
    By vinny gracindo in forum Newbie
    Replies: 3
    Last Post: 20th October 2009, 13:26
  2. QObject::connect stalls
    By arkain in forum Qt Programming
    Replies: 2
    Last Post: 26th April 2009, 00:26
  3. QObject::connect (fast)
    By baray98 in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2008, 06:30
  4. QObject::connect: No such signal
    By caseyong in forum Qt Programming
    Replies: 5
    Last Post: 19th February 2008, 07:23
  5. Replies: 4
    Last Post: 10th November 2006, 15:38

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.