Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to close QDockWidget from code?

How to close QDockWidget from code?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kitfox
    wrote on last edited by
    #1

    I have an app with a main window and several helper windows displayed in QDockWidgets. I'm trying to implement a menu I can use to toggle whether a particular helper window is visible.

    My helper windows are QWidgets placed inside QDockWidgets. I've tried calling close() and deleteLater() on the QDockWidget (when I select a menu option), but it is not removed from the main window. I've also called myDock->setAttribute(Qt::WA_DeleteOnClose);, but that did not help either.

    How can I close my dock pane?

    jsulmJ 1 Reply Last reply
    0
    • YunusY Offline
      YunusY Offline
      Yunus
      wrote on last edited by
      #2

      @kitfox It is interesting why those functions dont work. You may also try to make visibility false. If it doesnt work either, there can be a loop or somthing like that in code. Maybe it is better to share the code with us

      K 1 Reply Last reply
      1
      • K kitfox

        I have an app with a main window and several helper windows displayed in QDockWidgets. I'm trying to implement a menu I can use to toggle whether a particular helper window is visible.

        My helper windows are QWidgets placed inside QDockWidgets. I've tried calling close() and deleteLater() on the QDockWidget (when I select a menu option), but it is not removed from the main window. I've also called myDock->setAttribute(Qt::WA_DeleteOnClose);, but that did not help either.

        How can I close my dock pane?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @kitfox Why don't you use QMenu to show a menu?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • YunusY Yunus

          @kitfox It is interesting why those functions dont work. You may also try to make visibility false. If it doesnt work either, there can be a loop or somthing like that in code. Maybe it is better to share the code with us

          K Offline
          K Offline
          kitfox
          wrote on last edited by
          #4

          @Yunus Looks like close() does work. There error was elsewhere in my code.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved