Results 1 to 12 of 12

Thread: signals/slot functions not automatically generated in the .cpp or .h file?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: signals/slot functions not automatically generated in the .cpp or .h file?

    No, the receiver of the signal should a be a slot that creates and shows the dialog: you had one called actionTest() in your main window class. The dialog object doesn't exist until you create it.

    Your connect() calls are broken and should be generating a compiler error or runtime warning. The arguments to the connect() are:
    • A pointer to the sender QObject
    • the SIGNAL() being sent
    • A pointer to the receiving object
    • the SLOT() receiving the signals when sent


    So, with the slot in your main window class renamed doStuff() to highlight the distinction from the actionTest QAction:
    Qt Code:
    1. connect(ui->actionTest, SIGNAL(triggered()), this, SLOT(doStuff()));
    To copy to clipboard, switch view to plain text mode 
    is closer to the mark.

  2. #2
    Join Date
    Dec 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: signals/slot functions not automatically generated in the .cpp or .h file?

    It works! I think I have a better handle on this now that I see how it works. Thanks very much for your help.

    Joe

Similar Threads

  1. Replies: 3
    Last Post: 6th December 2010, 14:23
  2. Replies: 7
    Last Post: 25th November 2009, 12:10
  3. Replies: 0
    Last Post: 1st August 2009, 08:05
  4. Replies: 2
    Last Post: 20th December 2008, 05:17
  5. SLOT or functions
    By mickey in forum Newbie
    Replies: 1
    Last Post: 8th February 2006, 18:45

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.