Results 1 to 4 of 4

Thread: 'X' button signal

  1. #1
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    121
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 'X' button signal

    How do I catch the signal from the main application 'X' button, used to terminate the application?

  2. #2
    Join Date
    Feb 2013
    Posts
    71
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Platforms
    Windows

    Default Re: 'X' button signal

    on your header add these:
    Qt Code:
    1. private slots: xButtonPressed();
    2. private: QPushButton *x;
    To copy to clipboard, switch view to plain text mode 
    and then on you c++ file add this.
    Qt Code:
    1. connect(xButton,SIGNAL(clicked()),this,xButtonPressed()));
    2. MainWindowName::xButtonPressed(){
    3. //app close function
    4. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    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: 'X' button signal

    How do I catch the signal from the main application 'X' button
    You don't, it doesn't emit a Qt signal. You can intercept the closing of your program by re-implementing the QWidget::closeEvent() of your top level widget class.

  4. #4
    Join Date
    Sep 2012
    Location
    Pune, India
    Posts
    18
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 'X' button signal

    I hope you are talking about close (X) button at right hand side of title bar of the window. If it is so then.

    Yes totally.. It doesn't emit any signal. There is closeEvent() of QWidget either you have to re-implement it, otherwise you can try using event filters.

Similar Threads

  1. emitting a signal with no button?
    By kja in forum Newbie
    Replies: 3
    Last Post: 29th November 2010, 21:33
  2. Connecting Button with Quit-Signal
    By moatilliatta in forum Qt Programming
    Replies: 1
    Last Post: 11th October 2010, 16:19
  3. Simulating a Button Click signal
    By Ratheendrans in forum Qt Programming
    Replies: 4
    Last Post: 5th May 2010, 11:57
  4. how to know which button emit the signal?
    By coder1985 in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2008, 14:26
  5. Connecting signal to button
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 13th December 2007, 10:37

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.