[PyQt] Upgrading from static to dock widgets?

Kyle Altendorf sda at fstab.net
Wed Jun 26 12:23:33 BST 2019


Side note, perhaps something like below would be of interest to you.  It
would require wrapping it for Python but hopefully SIP would make that
'easy'.  I've been meaning to do that myself for awhile but haven't
gotten to it yet. 

https://github.com/richardjdare/Qt-Advanced-Docking-System 

Cheers, 

-kyle 

On 2019-06-26 05:33, Matic Kukovec wrote:

> Hi guys, 
> 
> I have an application that uses three QTabWidgets in a QGroupBox as the central widget.
> This works great and I have implemented dragging of tabs between these three widgets. 
> 
> To upgrade to docking, I would wrap each QTabWidget in a QDockWidget and remove it's titlebar with 'setTitleBarWidget', as I don't want a titlebar. I would also remove the central widget and just have three QDockWidget's docked somewhere. 
> My questions are: 
> 
> * I would upgrade the QTabWidget to wrap a dragged tab by putting it inside a new QTabWidget and putting it into a QDockWidget automatically on the fly.
> How can I then manually initiate a 'dock move' when I drag one of the tabs from a QTabWidget after the dragged tab widget was wrapped as described in the previous sentence? 
> * I tried playing around with QDockWidgets to figure out how to make them movable to any space (above, below, left, right) of any other QDockWidget, but the way in which they can be moved is limited to what area they were initialized in. For example if I add 4 dockwidgets to the QMainWindow with the 'self.addDockWidget(Qt.TopDockWidgetArea, dockwidget)', I can only move them side-by-side, I cannot move one above or below another. What am I missing? My test Example:
> from PyQt5.QtWidgets import *
> 
> from PyQt5.QtGui import * 
> from PyQt5.QtCore import * 
> import sys 
> 
> class Window(QMainWindow): 
> def __init__(self): 
> super().__init__() 
> 
> title = "DockAble Application" 
> top = 400 
> left = 400 
> width = 600 
> height = 500 
> 
> self.setWindowTitle(title) 
> self.setGeometry(top,left, width, height) 
> 
> self.dockAble() 
> 
> def dockAble(self): 
> for i in range(3): 
> dock = QDockWidget("Test widget", self) 
> dock.setAllowedAreas(Qt.AllDockWidgetAreas) 
> self.addDockWidget(Qt.TopDockWidgetArea, dock) 
> 
> app = QApplication(sys.argv) 
> window = Window() 
> window.show() app.exec() 
> 
> Thanks, 
> Matic
> 
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190626/7d9a05d7/attachment.html>


More information about the PyQt mailing list