Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    [SOLVED]CloseEvent() when closing of a QDocWidget created with Designer?

    Tools
    2
    3
    1294
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      FRAUBRJ last edited by

      Hello
      I built my application with Qt Designer for the UI part. A main window (QWidget) where does the program, and several auxiliary Windows (QDockWidget) I call to make the settings.
      An auxiliary window appears when the menu is selected (Preferences…).
      My program begins with

      @//-----------------------------------------------------------------------------
      // My_MainWindow Constructor
      //-----------------------------------------------------------------------------
      My_MainWindow::My_MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::My_MainWindow)
      {
      ui->setupUi(this);
      .....
      createActions();
      createMenus();
      .....
      prefAction = new QAction("&Preferences", this);
      connect(prefAction, SIGNAL(triggered()), this, SLOT(preferenceAct()));
      .....
      }

      //-----------------------------------------------------------------------------
      // SLOT preferenceAct
      //-----------------------------------------------------------------------------
      void My_MainWindow::preferenceAct(void)
      {
      ui->prefDockWidget->show();
      }
      @

      I close prefDockWidget by the close button (X). How to use the event generated?
      I think I have to redefine the XXXX::CloseEvent(QCloseEvent *event) method that is called at this time.
      How to do this from the only info I have: ui-> prefDockWidget?

      1 Reply Last reply Reply Quote 0
      • C
        cincirin last edited by

        QDockWidget has "toggleViewAction":http://qt-project.org/doc/qt-4.8/qdockwidget.html#toggleViewAction method which returns pointer to QAction.
        Then connect your slot to "QAction::toggled":http://qt-project.org/doc/qt-4.8/qaction.html#toggled When "checked" parameter is true, your dock widget is showed, else is closed

        1 Reply Last reply Reply Quote 0
        • F
          FRAUBRJ last edited by

          Thanks cincirin, it works perfectly!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post