Results 1 to 2 of 2

Thread: How to handle Close Event ?

  1. #1
    Join Date
    Jan 2012
    Qt products
    Qt3 Qt4

    Default How to handle Close Event ?

    My Application has a QTabWidget as the central widget. I want to implement dock/undock functionality for its tabs. Each tab has a button and a local variable to save its state (dock or undock).

    Qt Code:
    1. ....
    2. bool isDocked = true;
    3. ....
    To copy to clipboard, switch view to plain text mode 
    inside button click event

    Qt Code:
    1. if (isDocked)
    2. {
    3. ....
    4. removePage(tab);
    5. tab->reparent(0, QPoint(0,0), true);
    6. isDocked = false;
    7. }
    8. else
    9. {
    10. ....
    11. addTab(tab, name);
    12. isDocked = true;
    13. }
    To copy to clipboard, switch view to plain text mode 
    This works fine. My problem is the close event. If the tab is Undocked, it appears as a top level widget(with min/max/close buttons). If the user clicked the close button tab should be docked. I have reimplemented tab's closeEvent to get this functionality. closeEvent implementation is same as the button clicked implementation. but it works first time only. after that if i press the close button it does nothing. What can be the problem ? I am using Qt 3. thanks.

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: How to handle Close Event ?

    Show us the complete code for the closeEvent.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.

Similar Threads

  1. How to handle mousehover event on a label?
    By moiit in forum Qt Programming
    Replies: 5
    Last Post: 28th January 2011, 04:16
  2. Replies: 2
    Last Post: 17th December 2010, 20:01
  3. HOw to handle checkBox event occured in qlistwidget
    By sanket.mehta in forum Qt Programming
    Replies: 0
    Last Post: 16th November 2010, 10:36
  4. Replies: 0
    Last Post: 15th June 2010, 10:12
  5. Close event
    By gyre in forum Newbie
    Replies: 3
    Last Post: 20th November 2007, 14:49

Tags for this Thread


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.