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.
5 Réponses
+ 6
Ketan Lalcheta ,
have you tried it this way?
...
auto dialog2 = new QDockWidget(dialog1);
^^^^
+ 1
Yeah my bad. It was set as pointer only with new.but still It does not work
+ 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?
0
dialog1->setWidget(dialog2);
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?