Results 1 to 4 of 4

Thread: Is there a way to pair 2 top level windows?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Is there a way to pair 2 top level windows?

    Thanks for the response. What signal should I be using to determine if the X (close) button on window 1 has been clicked?

  2. #2
    Join Date
    Jul 2010
    Posts
    21
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is there a way to pair 2 top level windows?

    Install an event filter to detect QEvent::Close, e.g.

    Qt Code:
    1. #include <QtGui>
    2.  
    3. class EventSignaller : public QObject
    4. {
    5. Q_OBJECT
    6.  
    7. signals:
    8. void closing();
    9.  
    10. protected:
    11. bool eventFilter(QObject *object, QEvent *event)
    12. {
    13. if(event->type() == QEvent::Close)
    14. emit(closing());
    15.  
    16. return QObject::eventFilter(object, event);
    17. }
    18. };
    19.  
    20. int main(int argc, char *argv[])
    21. {
    22. QApplication app(argc, argv);
    23.  
    24. QWidget w1;
    25. w1.setWindowTitle("w1");
    26. w1.show();
    27.  
    28. QWidget w2;
    29. w2.setWindowTitle("w2");
    30. w2.show();
    31.  
    32. EventSignaller s;
    33. w1.installEventFilter(&s);
    34. w2.connect(&s, SIGNAL(closing()), SLOT(close()));
    35.  
    36. return app.exec();
    37. }
    38.  
    39. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 0
    Last Post: 22nd March 2010, 18:00
  2. A pair of emails questions
    By Raccoon29 in forum Qt Programming
    Replies: 4
    Last Post: 28th December 2009, 23:10
  3. Replies: 3
    Last Post: 27th December 2009, 00:00
  4. How create a two level table?
    By kaushal_gaurav in forum Qt Programming
    Replies: 3
    Last Post: 29th October 2008, 18:16
  5. Replies: 4
    Last Post: 4th June 2007, 12:07

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.