All posts tagged Qt

Autodesk just recently released Maya 2017. Which means another round of updates for my two available plugins; sePushPullConstraint and seUVBlendShape. The big change this time around was the update to Qt version 5. Though the conversion from version 4 to 5 is not that difficult, it does make it incompatible between the two versions. Thankfully, someone has already wrote a nice Python module to make the code work in both. So for those tools that are using PyQt and want to make their user interfaces compatible, take a look at this handy code.

That’s all the updates for now! Enjoy!

If you have used dock widgets in Qt, you may have docked with with tabs for easy stacking of other dock widgets. One handy feature of the tabs is when you click on the active tab, it will collapse the dock area and clicking a tab will expand it again. One thing however that is missing in Qt is a way to trigger this behavior yourself. If you simply hide the dock widget, the tab will disappear so that is no use. There is no slot or function to control the action. After lots of investigating I came to the conclusion that there is some custom Qt event handling specifically for mouse button clicks on a dock widget tab.  Triggering this event causes some way to hide the dock but keep the tabs using some other special method. The Qt source code doesn’t expose this either so there is no way to find what is happening and recreate it yourself.

But I didn’t give up, I wanted my tabbed dock widgets to be collapsed upon opening the UI to keep tools that are not needing to be seen from distracting the user. So how can I trigger this behavior programmatically? Well, I simulate a mouse button click event on the tab so I trick Qt on thinking the user did click on the tab! By creating my own QMouseEvent, I send the event to the tab bar with the position of where the “click” happened and let the tab bar handle what it does, which is collapse/expand the dock widget. Simple!

Below is the code snippet I created to reproduce a mouse button press event over the tab that has the same text. Simply pass it a QMainWindow instance and the text on the tab you want to “click” on.  The return will be True if the tab was found and event was sent otherwise False. Now you can too programmatically trigger this feature which should have been included in the first place. By the way, this is for Qt 4.8, maybe future versions will support this.