Close event issues
-
I am trying to restore mdiArea subwindows AFTER a specific subwindow is closed.
After I click "X" on subwindow title bar if closes, no problem.
I do have "closeEvent" slot implemented and it gets executed.When I set a breakpoint on the first valid line in "closeEvent" SLOT function I expect the debugger to stop at the breakpoint and display it ...
It does not.
The application contnue to run normally, however, when I exit the app , then
editor will
show the breakpoint - as expected.And ONLY after the app is exited.
Am I missing some timing option to process "closeEvent"?.
If I delete the breakpoint the close event appears NOT to get fully processed,
I do not know where the app stops then.I can post the "debug" view if it helps.
ThanksLocals **TestCount 21845 int** ??? event @0x7fffffffc0d0 QCloseEvent [QEvent] @0x7fffffffc0d0 QEvent [type] QEvent::Close (0x0013) QEvent::Type [vptr] _vptr.QEvent staticMetaObject @0x7ffff5de5320 QMetaObject d 0x0 QEventPrivate* t 19 ushort posted 0 ushort{unsigned short} : 1 spont 0 ushort{unsigned short} : 1 m_accept 1 ushort{unsigned short} : 1 reserved 8191 ushort{unsigned short} : 13 match <not accessible> QString pList <not accessible> QList<QAction*> this "MainWindow_Bluetooth" MainWindow_Bluetooth Inspector Expressions "(?<=\thci0 <no such value> // subMenu[index] = subMenu[index] // ->addMenu(list[index] + SERIAL_SETUP SetupRun endif // //subtempmenu = new QMenu(); // m_ui->actionConnect processAction Return Value Tooltip
void MainWindow_Bluetooth::closeEvent( QCloseEvent* event ) { //emit MySignalToIndicateThatTheWindowIsClosing(); #ifdef RETILE text = "\n #ifdef RETILE\n"; //exit(56); text = "\t EVENT QCloseEvent* event PASSED to parent \n"; text += " void MainWindow_Bluetooth::closeEvent( QCloseEvent* event ) "; text += Q_FUNC_INFO; text += "\n @ line # "; text += QString::number(__LINE__); qDebug().noquote()<<text; #endif
-
@AnneRanch said in Close event issues:
"closeEvent" SLOT function
closeEvent
is a function, not a slot.AFTER a specific subwindow is closed
void MainWindow_Bluetooth::closeEvent( QCloseEvent* event )
The close event is delivered to the subwindow, that closes. The main window doesn't close, that's why its
closeEvent()
override isn't called. -
C Christian Ehrlicher moved this topic from C++ Gurus on
-
@Axel-Spoerl
Additional to this. If you look at the OP's first "box paste". I'm not sure how they get it, but it looks like it is showing what is in the debugger windows, somehow? Then see this section:Expressions "(?<=\thci0 <no such value> // subMenu[index] = subMenu[index] // ->addMenu(list[index] + SERIAL_SETUP SetupRun endif // //subtempmenu = new QMenu(); // m_ui->actionConnect processAction
Assuming that is what the OP has in the debugger's Watch/Expressions pane it looks like they have pasted C++ statements/fragments into that. I am wondering if that is not helpful when these have to be evaluated every time the debugger breaks?
-
Thanks for replies. I am sorry I did include irrelevant, to solve this issue, view. In an essence - I want to retile the subwindows. The "closeevent", according to doc . MAYBE passed all the way to where "tile Subwindows" action can be executed.
That would eventually allowed common "closeEvent " for all subwindows. Since it is "maybe" and currently does not work, allow me to go back to process "closeEvent " in subwindow.
Then I need code help letting subwindow "closeEvent " access to higher level of object hierarchy - Qt call it parent..Here is my "SettingsDialog" "closeEvent " code so far.
{
#ifdef RETILE
text = "\t#i#ifdef RETILE \n";
text += "TRACE START Retile mdiArea subwindows .... ";
text += " ";
//text += " TASK initActionsConnections() ";
text += Q_FUNC_INFO;
text += QString::number(LINE);
qDebug().noquote() << text;text =" parent ???"; text += parent()->objectName(); qDebug().noquote() << text;
#endif
event->accept(); // what does it do ?? // this children (objects) of this QList<QObject*> pL = this->findChildren<QObject*>(); foreach(auto *item, pL) { text = item->objectName(); qDebug()<<text; } // parent - up children (objects) of parent QList<QObject*> pLParent = parent()->findChildren<QObject*>(); foreach(auto *item, pLParent) { text = item->objectName(); qDebug()<<text; } QList<QAction*> pLParent_Action = parent()->findChildren<QAction*>(); foreach(auto *item, pLParent_Action ) { text = item->objectName(); qDebug()<<text; }
So far none of the above gives access to "tileSubwindoiws" action code in "parent" .
-
Dear @AnneRanch,
Is
settingsWindow
the subwindow, where you want to overridecloseEvent()
?
If so, please format your code, then I'll read it. -
ADDENDUM
I believe the problem is "higher up ".
That attached code gives no "parent" name, whatever the function "parent()" is actually doing.I am not sure if passing "parent" as passed pointer and also having a function called "parent()" is a issue.
void SettingsDialog::closeEvent( QCloseEvent* event )
{#ifdef RETILE
text = "\t#ifdef RETILE \n";
text += "TRACE START Retile mdiArea subwindows .... ";
text += " ";
//text += " TASK initActionsConnections() ";
text += Q_FUNC_INFO;
text += QString::number(LINE);
qDebug().noquote() << text;
#endif
#ifdef RETILE
// DEBUG
text =" parent ???";
text += parent()->objectName(); // DEBUG no data here
qDebug().noquote() << text;
#endif
#ifdef RETILE
text = " this->parent()->objectName() ";
text += this->parent()->objectName();
qDebug().noquote() << text;
#endifthis->
#ifdef RETILE
// DEBUG
text =" parent ???";
text += parent()->objectName(); // DEBUG no data here
qDebug().noquote() << text;
#endif
#ifdef RETILE
text = " this->parent()->objectName() ";
text += this->parent()->objectName();
qDebug().noquote() << text;
#endifthis->
-
PS The code attached was previously formatted , using "quick reply" , this time it was not formatted.
-
Not to worry, I'll delete this AFTER the issue is solved .
I think this shows the object hirerarch shloul lead to code required to retrieve access to ""actionTile_subwindows" QAction".....
Locals event @0x7fffffffca20 QCloseEvent mdiParent @0x7ffff4ea5453 QMdiSubWindow pActions <not accessible> QList<QAction*> pL <not accessible> QList<QObject*> pLParent <not accessible> QList<QObject*> pLParent_Action <not accessible> QList<QAction*> pOBJECT 0x5d0000006e QWidget* pTEST @0x7fffffffc550 QWidget this "SettingsDialog" SettingsDialog [QDialog] "SettingsDialog" QDialog [d] @0x555555d923e0 QDialogPrivate [parent] @0x555555de3310 QMdiSubWindow [QWidget] @0x555555de3310 QWidget [d] @0x5555556d1000 QMdiSubWindowPrivate [parent] @0x555555c30e80 QWidget [QObject] @0x555555c30e80 QObject [QPaintDevice] @0x555555c30e90 QPaintDevice [d] @0x555555c30ec0 QWidgetPrivate [parent] @0x555555c64250 QMdiArea [QAbstractScrollArea] @0x555555c64250 QAbstractScrollArea [d] @0x5555559ff1a0 QMdiAreaPrivate [parent] "MainWindow_Bluetooth" MainWindow_Bluetooth [QMainWindow] "MainWindow_Bluetooth" QMainWindow [d] @0x555555c2ed00 QMainWindowPrivate [parent] @0x555555ccf290 QMdiSubWindow [children] <35 items> QList<QObject*> [0] "_layout" QMainWindowLayout [1] @0x555555c64250 QMdiArea [2] "SettingsDialog" SettingsDialog [3] @0x555555cdddc0 QSerialPort [4] "actionAbout" QAction [5] "actionAboutQt" QAction [6] "actionConnect" QAction [7] "actionDisconnect" QAction [8] "actionConfigure" QAction [9] "actionClear" QAction [10] "actionQuit" QAction [11] "actionVirtual_serial_port" QAction [12] "actionBluetooth_virtual_port" QAction [13] "actionBluetooth" QAction [14] "actionBluetooith_virtiual_port" QAction [15] "actionBluetooth_service_enable" QAction [16] "actionWinsow_control" QAction [17] "actionWindoiw_control" QAction [18] "actionTEST_tile" QAction [19] "actionTEST_resize" QAction [20] "actionTile_subwindows" QAction [21] "actionCascade_subwindows" QAction [22] "actionMaximize_current_subwindow" QAction [23] "actionTEST" QAction [24] "actionSubmenu_1" QAction [25] "actionSubmenuy_2" QAction [26] "actionClear_all_windoiws" QAction [27] "actionClear_all_windiws" QAction [28] "actionSerial_test" QAction [29] "actionSerial_test_2" QAction [30] "actionC_code_scan" QAction [31] "actionSelect_MDI_subwindow_MDI_window_control" QAction [32] "menuBar" QMenuBar [33] "mainToolBar" QToolBar [34] "statusBar" QStatusBar [properties] <at least 0 items> [methods] <20 items> [extra] Menu_Index 0 int command 0x0 char* index 8 int index_sub 0 int list_array @0x555555bd2370 QStringList[10] m_TAB_CommonDebug "A_BT_TAB_DIALOG" A_BT_TAB_DIALOG m_TAB_Connect 0x0 A_BT_TAB_DIALOG* m_TAB_Ext 0x0 A_BT_TAB_DIALOG_EXT* m_console @0x555555c314f0 Console m_mdiarea @0x555555c64250 QMdiArea m_serial @0x555555cdddc0 QSerialPort m_settings "SettingsDialog" SettingsDialog m_settings_RFcomm 0x0 SettingsDialog_RFcomm* m_status @0x555555c64370 QLabel m_ui @0x5555556735a0 Ui::MainWindow_Bluetooth mainAction @0x555555bd24c8 QAction*[16] result "" QString subAction @0x555555bd23c8 QAction*[16] subMenu @0x555555bd2448 QMenu*[16] text " Parent console (case 7) " QString verify @0x555555bd2570 QStringList[16] [children] <3 items> QList<QObject*> [0] "qt_scrollarea_hcontainer" QAbstractScrollAreaScrollBarContainer [1] "qt_scrollarea_vcontainer" QAbstractScrollAreaScrollBarContainer [2] @0x555555c30e80 QWidget [properties] <at least 8 items> [methods] <14 items> [extra] [children] <6 items> QList<QObject*> [properties] <at least 59 items> [methods] <27 items> [0] windowTitleChanged [nameindex] 1 [type] signal [argc] 1 [parameter] 149 [tag] 2 [flags] 6 [localindex] 0 [globalindex] 5 [1] windowIconChanged [nameindex] 4 [type] signal [argc] 1 [parameter] 152 [tag] 2 [flags] 6 [localindex] 1 [globalindex] 6 [2] windowIconTextChanged [nameindex] 6 [type] signal [argc] 1 [parameter] 155 [tag] 2 [flags] 6 [localindex] 2 [globalindex] 7 [3] customContextMenuRequested [nameindex] 8 [type] signal [argc] 1 [parameter] 158 [tag] 2 [flags] 6 [localindex] 3 [globalindex] 8 [4] setEnabled [nameindex] 10 [type] slot [argc] 1 [parameter] 161 [tag] 2 [flags] 10 [localindex] 4 [globalindex] 9 [5] setDisabled [nameindex] 11 [type] slot [argc] 1 [parameter] 164 [tag] 2 [flags] 10 [localindex] 5 [globalindex] 10 [6] setWindowModified [nameindex] 12 [type] slot [argc] 1 [parameter] 167 [tag] 2 [flags] 10 [localindex] 6 [globalindex] 11 [7] setWindowTitle [nameindex] 13 [type] slot [argc] 1 [parameter] 170 [tag] 2 [flags] 10 [localindex] 7 [globalindex] 12 [8] setStyleSheet [nameindex] 14 [type] slot [argc] 1 [parameter] 173 [tag] 2 [flags] 10 [localindex] 8 [globalindex] 13 [9] setFocus [nameindex] 16 [type] slot [argc] 0 [parameter] 176 [tag] 2 [flags] 10 [localindex] 9 [globalindex] 14 [10] update [nameindex] 17 [type] slot [argc] 0 [parameter] 177 [tag] 2 [flags] 10 [localindex] 10 [globalindex] 15 [11] repaint [nameindex] 18 [type] slot [argc] 0 [parameter] 178 [tag] 2 [flags] 10 [localindex] 11 [globalindex] 16 [12] setVisible [nameindex] 19 [type] slot [argc] 1 [parameter] 179 [tag] 2 [flags] 10 [localindex] 12 [globalindex] 17 [13] setHidden [nameindex] 21 [type] slot [argc] 1 [parameter] 182 [tag] 2 [flags] 10 [localindex] 13 [globalindex] 18 [14] show [nameindex] 23 [type] slot [argc] 0 [parameter] 185 [tag] 2 [flags] 10 [localindex] 14 [globalindex] 19 [15] hide [nameindex] 24 [type] slot [argc] 0 [parameter] 186 [tag] 2 [flags] 10 [localindex] 15 [globalindex] 20 [16] showMinimized [nameindex] 25 [type] slot [argc] 0 [parameter] 187 [tag] 2 [flags] 10 [localindex] 16 [globalindex] 21 [17] showMaximized [nameindex] 26 [type] slot [argc] 0 [parameter] 188 [tag] 2 [flags] 10 [localindex] 17 [globalindex] 22 [18] showFullScreen [nameindex] 27 [type] slot [argc] 0 [parameter] 189 [tag] 2 [flags] 10 [localindex] 18 [globalindex] 23 [19] showNormal [nameindex] 28 [type] slot [argc] 0 [parameter] 190 [tag] 2 [flags] 10 [localindex] 19 [globalindex] 24 [20] close [nameindex] 29 [type] slot [argc] 0 [parameter] 191 [tag] 2 [flags] 10 [localindex] 20 [globalindex] 25 [21] raise [nameindex] 30 [type] slot [argc] 0 [parameter] 192 [tag] 2 [flags] 10 [localindex] 21 [globalindex] 26 [22] lower [nameindex] 31 [type] slot [argc] 0 [parameter] 193 [tag] 2 [flags] 10 [localindex] 22 [globalindex] 27 [23] updateMicroFocus [nameindex] 32 [type] <unknown> [argc] 0 [parameter] 194 [tag] 2 [flags] 9 [localindex] 23 [globalindex] 28 [24] _q_showIfNotHidden [nameindex] 33 [type] <unknown> [argc] 0 [parameter] 195 [tag] 2 [flags] 8 [localindex] 24 [globalindex] 29 [25] grab [nameindex] 34 [type] <unknown> [argc] 1 [parameter] 196 [tag] 2 [flags] 2 [localindex] 25 [globalindex] 30 [26] grab [nameindex] 34 [type] <unknown> [argc] 0 [parameter] 199 [tag] 2 [flags] 34 [localindex] 26 [globalindex] 31 [extra] data @0x555555c30fe0 QWidgetData [children] <4 items> QList<QObject*> [properties] <at least 2 items> [methods] <7 items> [extra] [children] <8 items> QList<QObject*> [properties] <at least 0 items> [methods] <8 items> [extra] ConnectIndex 1 int ConnectParent "MainWindow_Bluetooth" MainWindow_Bluetooth ConnectText " TEST SettingsDialog Constructor (emit index 1 ) " QString m_TAB_CommonDebug 0x0 A_BT_TAB_DIALOG* m_TAB_Connect "A_BT_TAB_DIALOG" A_BT_TAB_DIALOG m_TAB_Ext "A_BT_TAB_DIALOG_EXT" A_BT_TAB_DIALOG_EXT m_currentSettings @0x555555d86c88 SettingsDialog::Settings m_intValidator @0x555555dc61c0 QIntValidator m_status @0x555555dc5af0 QLabel m_ui @0x555555cb7d90 Ui::SettingsDialog pTAB "A_BT_TAB_DIALOG" A_BT_TAB_DIALOG staticMetaObject @0x7ffff7f03560 QMetaObject statusBar @0x555555dd75f0 QStatusBar text " this->parent()->objectName() " QString Inspector Expressions "(?<=\thci0 <no such value> // subMenu[index] = subMenu[index] // ->addMenu(list[index] + SERIAL_SETUP SetupRun endif // //subtempmenu = new QMenu(); // m_ui->actionConnect processAction qDebug().noquote() << text; Return Value Tooltip
-
@AnneRanch
As I said in an earlier post, you simply do not want to do this via parentage andparent
s. YourcloseEvent()
should emit a signal you define and where yourQMdiArea
is youconnect()
that signal to thetileSubWindows()
slot. No parentage, no object hierarchy, it's 100% what signals/slots are for. -
You can’t format code in quick reply. You have to press the button with the two diagonal arrows, left from quick reply.