Results 1 to 4 of 4

Thread: Custom Widget Connections

  1. #1
    Join Date
    Jun 2007
    Posts
    4
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Custom Widget Connections

    Hi I'm currently working on book about programming kde
    http://www.beginning-kdevelop-programming.co.uk/
    if you want a look

    I'm currently working custom widgets using a square button example and I'm having a problem understanding the connection logic.
    Everything is fine and I add the custom widget to the environment and then add it to a form but when it comes to the connection if I put

    connect( kSquareButtonTest, SIGNAL( clicked() ), this, SLOT( kSquareButtonTest_clicked() ) );

    in the implementation class constructor the compiler complains that there's no matching function for the connect call. Yet if I add the signal/slot through the designer it writes

    connect( kSquareButtonTest, SIGNAL( clicked() ), this, SLOT( kSquareButtonTest_clicked() ) );

    in the widgetbase class and everything works fine. I suspect there's a bit of plumbing going on that I've missed and was wondering if someone could explain it to me.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Custom Widget Connections

    Did you declare that slot in the class header?

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget Connections

    Do you still get the error if you use:
    Qt Code:
    1. QObject::connect( kSquareButtonTest, SIGNAL( clicked() ), this, SLOT( kSquareButtonTest_clicked() ) );
    To copy to clipboard, switch view to plain text mode 
    ?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Jun 2007
    Posts
    4
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Red face Re: Custom Widget Connections

    My bad

    I hadn't included the header file for the custom widget in the implementation file so when the compiler was complaining about the connect function it sent me off in the wrong direction because it didn't tell me that the kSquareButtonTest object wasn't defined properly

Similar Threads

  1. Custom Shape Widget (resize)
    By PiXeL16 in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2007, 07:00
  2. Replies: 1
    Last Post: 5th November 2006, 23:50
  3. Problem applying setWindowOpacity to a custom Widget
    By yellowmat in forum Qt Programming
    Replies: 8
    Last Post: 1st November 2006, 10:05
  4. Replies: 3
    Last Post: 12th April 2006, 08:20
  5. Replies: 4
    Last Post: 24th March 2006, 22:50

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.