0

Two dialog of QT and parent child

I have created two objects of type QDockWidget as below: auto dialog1 = QDockWidget(nullptr) auto dialog2 = QDockWidget(dialog1) Does this mean that dialog1 is parent dialog for dialog2? If not, how to set one dialog as parent of other dialog? If I am doing dialog1 ->children() for dialog1 , then why I am not getting dialog2 as child? Unfortunately, I had to do this through C++ code and not through QT designer.

13th Dec 2024, 2:31 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
5 Answers
+ 6
Ketan Lalcheta , have you tried it this way? ... auto dialog2 = new QDockWidget(dialog1); ^^^^
13th Dec 2024, 3:17 PM
Lothar
Lothar - avatar
+ 1
Yeah my bad. It was set as pointer only with new.but still It does not work
14th Dec 2024, 4:12 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
I got parent child relationship working , but another issue is now present. Earlier, I got two windows and both dialog were having separate windows. Now, second dialog is embedded into first one. Can I have two windows (one window for each dialog) even though one dialog is parent of other dialog?
14th Dec 2024, 6:43 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
dialog1->setWidget(dialog2);
14th Dec 2024, 9:17 AM
RuntimeTerror
RuntimeTerror - avatar
0
Both dialog has now nullptr as parnt as below: auto dialog1 = QDockWidget(nullptr) auto dialog2 = QDockWidget(nullptr) Then , I am doing dialog2 ->setparent(dialog1) for dialog2 to make dialog 1 as its parent. Then , I am doing dialog2 ->setFloating(true) With this, I got parent child relationship and dialog 2 as new window also. But I cannot move dialog 2. I can move only dialog1. How to allow user to move dialog2 independently?
15th Dec 2024, 5:44 AM
Ketan Lalcheta
Ketan Lalcheta - avatar