[PyQt] Upgrading from static to dock widgets?

Matic Kukovec kukovecmatic at hotmail.com
Thu Jun 27 11:36:36 BST 2019


Hey Kyle,

If it was ported, it would be exactly what I need.
Unfortunately, I don't have any experience with SIP to be able to do it. But I will look into it, thanks.

If anyone else has other suggestions/solutions, please let me know.

Regards,
Matic
From: Kyle Altendorf <sda at fstab.net>
Sent: Wednesday, June 26, 2019 1:23 PM
To: Matic Kukovec
Cc: pyqt at riverbankcomputing.com
Subject: Re: [PyQt] Upgrading from static to dock widgets?


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<mailto:PyQt at riverbankcomputing.com>
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Hey guys,

I've got the docking anywhere working correctly, didn't know that at least one widget inside a dockwidget is needed for the docking to work correctly.

Now I am trying to emulate the behavior of click&dragging the dockwidget's titlebar, by having it work exactly the same when click&dragging the dockwidget's child's tab bar. I'm working with this 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()
        self.setDockOptions(self.dockOptions() & ~QMainWindow.AnimatedDocks)
        self.setDockNestingEnabled(True)

    def dockAble(self):
        for i in range(4):
            dock = QDockWidget("Employee", self)
            dock.setFloating(False)
            dock.setAllowedAreas(Qt.AllDockWidgetAreas)
            self.employee = ["John", "Doe", "Parwiz", "Bob"]
            tabw = QTabWidget(dock)
            listw = QListWidget(tabw)
            listw.addItems(self.employee)
            tabw.addTab(listw, "MyTab")
            dock.setWidget(tabw)
            self.addDockWidget(Qt.TopDockWidgetArea, dock)

app = QApplication(sys.argv)
window = Window()
window.show()
app.exec()

Can anyone give me a hint of where to start?

Thanks,
Matic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190627/d7acf03b/attachment-0001.html>


More information about the PyQt mailing list