PDA

View Full Version : [QDockWindow] destroy



villy
29th November 2006, 09:06
Hi all,
I've a problem when I try to "destroy" a QDockWindow. My application conists in a QMainWindow, with some dock windows. Each dock window has a pointer (QDockWindow *) and it's created dinamically with new operator. Well... I want to destroy dock windows when when they are close (with close button). So, I've captured signal visibiltyChanged(bool) emitted by dock window when they are shown or closed and connected to a slot where I make a delete on pointer.
My application crashes with message:
"QInputContext cannot create input context for non top-level widgets"

Can somebody help me?

Thanks...

wysota
29th November 2006, 09:18
Maybe it would be simpler if you set the "delete on close" flag for your widgets?

villy
29th November 2006, 10:07
I've tried to create dock window with Qt::WDestructiveClose flag, but it seem does nothing (I don't know why....)

I've resolved with this code (for the slot...) without call a delete... If I call a delete the application crash!



void WsGraphicsImpl::dockVisibilitySlot(bool visible)
{
QDockWindow *dock;

if (sender() != NULL && sender()->isA("QDockWindow")) {
dock = (QDockWindow *) sender();
if (dock == recordDock) {
if (!visible) {
dock->close();
removeDockWindow(dock);
}
}
}
}


In this way dock window is closed and is removed from the Main Window.

I've just a little question about the use of removeDockWindow method.
Why when I remove a dock windows with this method they still remain in list???????

Thanks

aamer4yu
29th November 2006, 10:44
try deleting the dock widget in the destructor of the main window...

villy
29th November 2006, 13:29
Ok, but I don't want to close the main window :)

wysota
29th November 2006, 22:05
You can't call delete on the sender from within a slot. Use deleteLater() instead. DestructiveClose should have worked though. Did you set it in the constructor?

villy
30th November 2006, 10:36
Great! deleteLater() has the same result of using close() with DestructiveClose (I set it in the constructor)!

wysota
30th November 2006, 13:51
(I set it in the constructor)!

Can I see the code?

villy
1st December 2006, 11:06
Simply, I create a new QDockWindow passing Qt::WDestructiveClose as WFlags value...



recordDock = new QDockWindow(QDockWindow::OutsideDock /*PLACE*/, this/*PARENT*/, "RECORD_DOCK" /*NAME*/, Qt::WDestructiveClose /*FLAGS*/);
...