[SOLVED]CloseEvent() when closing of a QDocWidget created with Designer?
-
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? -
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