BTW, note that you can omit the 3rd parameter in addTabifiedDockWidget()
and your dock widget will be tabified in that location, no matter which
dock widget is already placed there.

iface.addTabifiedDockWidget(Qt.RightDockWidgetArea, my_own_dock_widget)


On the other hand, if you really need to get existent dock widgets in a
given location, this function will do it:


def dockWidgetsInArea(area):
    dwa = []
    for dw in iface.mainWindow().findChildren(QDockWidget):
        if dw.isVisible() and iface.mainWindow().dockWidgetArea(dw) == area:
            dwa.append(dw)

    return dwa

Use it in this way:
dws = dockWidgetsInArea(Qt.RightDockWidgetArea)


Regards,

Germán


El jue, 13 jun 2024 a las 21:25, Germán Carrillo (<carrillo.ger...@gmail.com>)
escribió:

> Hi Luke,
>
>
> you can get a list of all QDockWidget objects in this way:
>
> iface.mainWindow().findChildren(QDockWidget)
>
> From there you could get objectNames, whether the dock widget is visible
> or not, its allowed areas and window title, among other properties.
>
> The objectName is relevant, because you can pass it as the 3rd parameter
> to addTabifiedDockWidget(), in this way:
>
> iface.addTabifiedDockWidget(Qt.RightDockWidgetArea, my_own_dock_widget,
> ["ProcessingToolbox"])
>
> In that way, your dock widget will be tabified taking the
> ProcessingToolbox dock widget as a reference. If you want your dock widget
> on top, pass an extra parameter raiseTab as True.
>
> I hope this helps.
>
>
> Regards,
>
> Germán
>
> El mié, 12 jun 2024 a las 20:22, Catania, Luke A ERDC-RDE-GRL-VA CIV via
> QGIS-Developer (<qgis-developer@lists.osgeo.org>) escribió:
>
>> How can I get the reference to a QDockWidget that is already docked.  I
>> want to call tabifyDockWidget so I can add a new QDockWidget to the same
>> location.  The first is already in place from exsiting code and I know I
>> can probably create a getter method on the code that adds the first doc
>> widget but I was hoping not add anything to that code and use some existing
>> built in method that would allow be to specify a dock widget location and
>> return a reference to what is currently docked at that location.
>>
>>
>>
>> Thanks,
>>
>> Luke
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>
>
> --
> -----------
>    |\__
> (:>__)(
>    |/
> Soluciones Geoinformáticas Libres
> http://geotux.tuxfamily.org/
> https://twitter.com/GeoTux2
> <http://twitter.com/GeoTux2>
>


-- 
-----------
   |\__
(:>__)(
   |/
Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/
https://twitter.com/GeoTux2 <http://twitter.com/GeoTux2>
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to