You can keep using the tabify method to switch the order of the tabs.
tabifyDockWidget(under, over)
import random
class MainWin(QtGui.QMainWindow):
def __init__(self):
super(MainWin, self).__init__()
prev = None
for i in xrange(5):
d = QtGui.QDockWidget("Dock %d" % i, self)
self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, d)
if prev:
self.tabifyDockWidget(prev, d)
prev = d
t = QtCore.QTimer(self)
t.timeout.connect(self.randomTab)
t.start(2000)
def randomTab(self):
a, b = random.sample(self.findChildren(QtGui.QDockWidget), 2)
print "Setting %s over %s" % (b.windowTitle(), a.windowTitle())
self.tabifyDockWidget(a, b)
On Sat, Aug 23, 2014 at 5:28 AM, David Martinez <
[email protected]> wrote:
> It occurs to me that one way of doing it would be to get all the 'Docks'
> that a given 'QMainWindow' has and then before adding a new one, I could do
> the following:
>
> # Creates second bottom Dock
> self.bottom_dock_02 = QDockWidget("Second Bottom Dock", self)
> self.bottom_dock_02.setObjectName('bottom_dock_02')
> self.bottom_dock_02.setAllowedAreas(Qt.BottomDockWidgetArea)
> self.widget_second_dock = QWidget(self.bottom_dock_02)
> self.widget_second_dock.setFixedHeight(150)
> self.bottom_dock_02.setWidget(self.widget_second_dock)
> self.addDockWidget(Qt.BottomDockWidgetArea, self.bottom_dock_02)
>
> existing_widget = None
>
> for current_dock in self.findChildren(QDockWidget):
> if self.dockWidgetArea(current_dock) ==
> Qt.BottomDockWidgetArea:
> existing_widget = current_dock
> break
>
> if existing_widget:
> self.tabifyDockWidget(self.bottom_dock_02,current_dock)
>
>
> Does that sound like a good way of doing it? If so, I have a couple of
> questions more:
>
>
> - Is it possible to change the order in which the items have been
> stacked? I'd like the user to be able to re-arrange them if they want to do
> so.
>
>
>
> Many thanks
>
>
>
> --
> David Martinez - Technical Animator
>
> Email: [email protected]
> Website: http://www.elusiveideas.com
>
>
>
>
> On Fri, Aug 22, 2014 at 5:58 PM, David Martinez <
> [email protected]> wrote:
>
>> Ah!
>>
>> I've got it working by adding the following line:
>>
>> self.tabifyDockWidget(self.bottom_dock_01,self.bottom_dock_02)
>>
>> Which brings me to my next question... How do I know if there are
>> 'QDockWidgets' already in one of the four zones? I'm asking because I'm
>> creating those dynamically and I will need to do the check before I try to
>> stack them.
>>
>> Cheers
>>
>>
>>
>> On Friday, August 22, 2014 1:43:33 PM UTC+1, David Martinez wrote:
>>>
>>> Hi,
>>>
>>> I have a question in regards on how the 'QDockWidget' works in
>>> 'PyQt/PySide'. I have an application that creates an instance of
>>> 'QMainWindow' and this one creates two 'QDockWidgets' in the bottom area.
>>>
>>> I'd like them to be stacked upon creation but instead they appear next
>>> to each other. Once the application is running, I can drop one on top of
>>> the other but I'd like to stack them when they get created. Is that
>>> possible?
>>>
>>> Here is some mock up code:
>>>
>>> https://gist.github.com/davidmartinezanim/6c69ca5cca39f390f89a
>>>
>>> (I know this way of importing is bad practice but it just for the sake
>>> of the example)
>>>
>>> Do you have any ideas about how to get this working the way I want?
>>>
>>>
>>> --
>>> David Martinez - Technical Animator
>>> Email: [email protected]
>>> Website: http://www.elusiveideas.com
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/e0d9289e-4208-44f4-8e6d-15a74125c401%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/e0d9289e-4208-44f4-8e6d-15a74125c401%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAMLeNpymBonZFOtmvmGNjsf%3Dpc4FYt_WihLZh3SvrE6hjKSLaw%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAMLeNpymBonZFOtmvmGNjsf%3Dpc4FYt_WihLZh3SvrE6hjKSLaw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2iz%3DbPvY8x38iQ5zCyUkSg7UTk4htkbSfYcLjWALSAeA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.