Results 1 to 2 of 2

Thread: Connecting Button with Quit-Signal

  1. #1
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Connecting Button with Quit-Signal

    Hello everyone,

    i have a button who should work like an exit button that appears at the end of my program. I used this line of code to realize it but it does not work at all.

    Qt Code:
    1. connect(endBtn, SIGNAL(clicked()), this, SLOT(quit()));
    To copy to clipboard, switch view to plain text mode 

    Is this because i do call the quit on "this" and not in the main.cpp? If yes, how do i connect the endBtn properly?

    Thank you very much.
    greetings
    moatilliatta
    boredom is the reflex to the objective grey

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Connecting Button with Quit-Signal

    You can use qApp macro to get a pointer to the QApplication instance,like this:
    Qt Code:
    1. connect(endBtn, SIGNAL(clicked()), qApp, SLOT(quit()));
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Zlatomir for this useful post:

    moatilliatta (11th October 2010)

Similar Threads

  1. Replies: 4
    Last Post: 27th November 2009, 13:00
  2. Connecting signal to custom slot?
    By dbrmik in forum Qt Tools
    Replies: 2
    Last Post: 30th April 2009, 09:28
  3. dynamic signal connecting
    By donglebob in forum Qt Programming
    Replies: 4
    Last Post: 19th November 2008, 09:58
  4. Connecting signal to button
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 13th December 2007, 10:37
  5. Connecting signal to form that is closing
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 18th May 2007, 07:54

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.