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. QDockWidget + Menu
Forum Updated to NodeBB v4.3 + New Features

QDockWidget + Menu

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.9k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    mirswith
    wrote on last edited by
    #1

    Hi,. This should be an easy one.

    I have a QDockWidget that I have tied to a menu using addAction( dock->toggleViewAction() );

    What I would like to do is have this dock not open when the program loads and the first time it is activated for it to be docked to Qt::BottomDockWidgetArea. I have managed to make it not load when my program does but when I activate it, it is floating.

    Any ideas?

    Thanks.

    -=ben

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Knacktus
      wrote on last edited by
      #2

      Hmm, the following works for me (Python code and ignore the stylesheet stuff ...):

      @import PyQt4.QtGui as QtGui
      import PyQt4.QtCore as QtCore

      class MyMainWindow(QtGui.QMainWindow):

      def __init__(self, parent=None):
          super(MyMainWindow, self).__init__(parent)
          self.menu_bar = self.menuBar()
          
          self.tool_bar = self.addToolBar("&Session")
          self.dock = QtGui.QDockWidget("Test")
          self.dock.setWidget(QtGui.QLabel("Test"))
          self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.dock)
          self.dock.hide()
          self.action = self.dock.toggleViewAction()
          self.tool_bar.addAction(self.action)
                  
          self.session_menu = self.menu_bar.addMenu("&Session")
      
          self.setStyleSheet("""
          * 
          { 
              background-color: blue;
          } 
          """)
          
          button = QtGui.QPushButton("Test")
          self.setCentralWidget(button)
      

      if name == "main":
      import sys
      app = QtGui.QApplication(sys.argv)
      main_window = MyMainWindow()
      main_window.show()
      app.exec_() @

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mirswith
        wrote on last edited by
        #3

        Thanks, that did it, I just needed to hide it right after adding it.

        -=ben

        1 Reply Last reply
        0

        • Login

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