Results 1 to 9 of 9

Thread: [QDockWindow] destroy

  1. #1
    Join Date
    Jul 2006
    Location
    Cagliari - Sardinia - Italy
    Posts
    26
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default [QDockWindow] destroy

    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...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [QDockWindow] destroy

    Maybe it would be simpler if you set the "delete on close" flag for your widgets?

  3. #3
    Join Date
    Jul 2006
    Location
    Cagliari - Sardinia - Italy
    Posts
    26
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: [QDockWindow] destroy

    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!

    Qt Code:
    1. void WsGraphicsImpl::dockVisibilitySlot(bool visible)
    2. {
    3. QDockWindow *dock;
    4.  
    5. if (sender() != NULL && sender()->isA("QDockWindow")) {
    6. dock = (QDockWindow *) sender();
    7. if (dock == recordDock) {
    8. if (!visible) {
    9. dock->close();
    10. removeDockWindow(dock);
    11. }
    12. }
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    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

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [QDockWindow] destroy

    try deleting the dock widget in the destructor of the main window...

  5. #5
    Join Date
    Jul 2006
    Location
    Cagliari - Sardinia - Italy
    Posts
    26
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: [QDockWindow] destroy

    Ok, but I don't want to close the main window

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [QDockWindow] destroy

    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?

  7. #7
    Join Date
    Jul 2006
    Location
    Cagliari - Sardinia - Italy
    Posts
    26
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: [QDockWindow] destroy

    Great! deleteLater() has the same result of using close() with DestructiveClose (I set it in the constructor)!

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [QDockWindow] destroy

    Quote Originally Posted by villy View Post
    (I set it in the constructor)!
    Can I see the code?

  9. #9
    Join Date
    Jul 2006
    Location
    Cagliari - Sardinia - Italy
    Posts
    26
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: [QDockWindow] destroy

    Simply, I create a new QDockWindow passing Qt::WDestructiveClose as WFlags value...

    Qt Code:
    1. recordDock = new QDockWindow(QDockWindow::OutsideDock /*PLACE*/, this/*PARENT*/, "RECORD_DOCK" /*NAME*/, Qt::WDestructiveClose /*FLAGS*/);
    2. ...
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Destroy() function
    By lewis in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2006, 19:55
  2. Replies: 1
    Last Post: 24th June 2006, 20:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.