4

Im trying to disable the close 'x' button, and I assumed that it would work by setting the DockWidgetFeature to only movable and floatable.

def CreateDockWidget (self):

    Pane = QtGui.QDockWidget()
    Pane.DockWidgetFeatures =  QtGui.QDockWidget.DockWidgetFloatable | QtGui.QDockWidget.DockWidgetMovable;
    Pane.setAllowedAreas( QtCore.Qt.LeftDockWidgetArea | QtCore.Qt.RightDockWidgetArea )
    textBox1 = QtGui.QTextEdit()
    Pane.setWidget(textBox1 )
    self.addDockWidget( QtCore.Qt.LeftDockWidgetArea, Pane )

Why doesn't the above work ? BTW, if I don't set floatable, it remains floatable until its undockable (floating) then I can't re-dock it. Why is that ?

thanks

thefog
  • 181
  • 1
  • 4
  • 13
  • Which OS are you using? From the [Qt docs for `QDockWidget`](http://qt-project.org/doc/qt-4.8/qdockwidget.html#DockWidgetFeature-enum): "On some systems the dock widget always has a close button when it's floating (for example on MacOS 10.5)." – user3419537 Nov 18 '14 at 15:39

1 Answers1

9

You were right, but you didn't actually set the features of your DockWidget. Call

Pane.setFeatures(QtGui.QDockWidget.DockWidgetFloatable | 
                 QtGui.QDockWidget.DockWidgetMovable)

instead of erasing DockWidgetFeatures with the assignment and you should be fine!

Fenikso
  • 9,251
  • 5
  • 44
  • 72