[PyQt] Upgrading from static to dock widgets?

Matic Kukovec kukovecmatic at hotmail.com
Wed Jun 26 13:33:32 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.

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.




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):

        title = "DockAble Application"
        top = 400
        left = 400
        width = 600
        height = 500

        self.setGeometry(top,left, width, height)


    def dockAble(self):
        for i in range(3):
            dock = QDockWidget("Test widget", self)
            self.addDockWidget(Qt.TopDockWidgetArea, dock)

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


PyQt mailing list    PyQt at riverbankcomputing.com<mailto:PyQt at riverbankcomputing.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190626/d65229a4/attachment.html>

More information about the PyQt mailing list