Results 1 to 2 of 2

Thread: How to handle 2 QmainWindow closing problems

  1. #1
    Join Date
    Oct 2009
    Posts
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to handle 2 QmainWindow closing problems

    Hi,
    Problem statement:
    say we have 2 QMainWindow say A & B.
    B is created from A on click of some button.
    note A is not made as parent of the B (A->B). So basically now both A and B are independent. I chose this method because i don't want to inherit the style-sheet properties from A. I want the default which qt provides for window B. I do have some style-sheet set for A.
    I want to close window B when A is closed if B is not closed already.

    Actually B is crated by click of a button in the central widget of mainwindow A.

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to handle 2 QmainWindow closing problems

    in the close event of A .. just close B

    Qt Code:
    1. void A::closeEvent(QCloseEvent*e)
    2. {
    3. b->close();
    4. e->accept();
    5. }
    To copy to clipboard, switch view to plain text mode 

    assuming you always keep the pointer of B with A

Similar Threads

  1. Problems with QMainWindow and layout
    By franco.amato in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 22:49
  2. QMainWindow : restorestate problems
    By fmariusd in forum Qt Programming
    Replies: 10
    Last Post: 30th October 2009, 08:05
  3. Replies: 1
    Last Post: 21st November 2008, 07:00
  4. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  5. run function before closing QMainWindow
    By raphaelf in forum Newbie
    Replies: 1
    Last Post: 31st August 2006, 09:21

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.