I am creating a dock widget for my plugin and i want my widget to be fixed to the Qgis window. How can i do that using python programming?
This question is perhaps better suited to StackOverflow, as it doesn't specifically relate to GIS (other than that the application you're using is QGIS).
To create a new dock widget and add it to the left panel:
dockwidget = QtGui.QDockWidget(iface.mainWindow()) iface.addDockWidget(Qt.LeftDockWidgetArea, dockwidget)
If the user moves it to a floating window you can then re-dock it using
If you want to prevent the user from moving it to a floating window you need to set the "features" of the widget. In the example below, the widget is movable and closable, but not floatable:
dockwidget.setFeatures(QtGui.QDockWidget.DockWidgetClosable | QtGui.QDockWidget.DockWidgetMovable)