Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Docked tool browser does not visually scroll, but it does when undocked

Docked tool browser does not visually scroll, but it does when undocked

Anonymous
Not applicable
1,727 Views
8 Replies
Message 1 of 9

Docked tool browser does not visually scroll, but it does when undocked

Anonymous
Not applicable

I'll try to explain this clearly.

 

All this worked in maya 2016, I'm trying to port it to the new 2017/2018 world. It's not originally my ui code and it's a bit complex, so I need a bit of help.

 

We have a toolBrowser (kind of like a vertical shelf with buttons).  There is a QTabWidget, within each tab a QStackedWidget, within that a custom scrolling ListView within which we have the custom button-like widgets.  It is all in a workspaceControl, so it docks nicely with the attribute editor.  The problem is that while the scrolling list works fine while the workspaceControl is floating, it appears to not scroll when docked.  It actually does scroll, but the display is not refreshed.  I can tell this because I can force a refresh by switching tabs, and then I can see the list has scrolled to where it should have.  The tool widgets in the ListView work fine.

What am I missing?  It's like the scrollbar part of the widget gets the mouse click and drag events, but it the widget not getting refreshed when the list is scrolled.  I'm a bit new to qt, so I'm sure I'm missing something obvious...

 

Thanks, Sumit

0 Likes
Accepted solutions (1)
1,728 Views
8 Replies
Replies (8)
Message 2 of 9

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Could you give us a sample? Maya 2017 uses Qt5 while Maya 2016 uses Qt4. There could be some differences.

 

Yours,

Li

0 Likes
Message 3 of 9

Anonymous
Not applicable

Thanks, I'll try to extract something manageable that demonstrates the problem.  I have already converted all the code to pyside2 and Qt5, but maybe I've missed something.  To be clear though, I was able to get it working when I did not use the new workspaceControl docking method (it used dockControl).  It did not dock in the correct place, so I'm trying to update it.  That's when I started getting the refresh/scrolling problem.

 

0 Likes
Message 4 of 9

Anonymous
Not applicable

OK, below is the top level of the code, hopefully the problem can be found in this snippet.

Thanks, Sumit

 

import os, sys
import maya.cmds
from Qt import QtCore, QtGui
import project.Cinematics.cgcore.qt.qt as qt

from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
form_class, base_class = qt.loadUiType("C:\\Maya2017_dev\\depot\\tools\\art_working\\python\\project\\Cinematics\\cgcore\\apps\\maya\\toolBrowser\\toolBrowserWindow.ui")

class ToolBrowserWindow(MayaQWidgetDockableMixin, base_class, form_class):
    def __init__(self, name):
        super(ToolBrowserWindow, self).__init__()
        
        self.setupUi(self)
        self._helperObj = toolBrowser.ToolBrowser()
        self.populateViewTabs()
        
        # Turn it into a workspaceControl so it will dock properly
        workspaceControlName = self.objectName() + 'WorkspaceControl'
    
        # this class is inheriting MayaQWidgetDockableMixin.show(), which will eventually call maya.cmds.workspaceControl.
        # I'm calling it again, since the MayaQWidgetDockableMixin dose not have the option to use the "tabToControl" flag,
        # which was the only way i found i can dock my window next to the channel controls, attributes editor and modelling toolkit.
        self.show(dockable=True, area='right', floating=True)
        mayaWorkspaceControl = maya.cmds.workspaceControl(workspaceControlName,
                                                          edit = True,
                                                          tabToControl=["AttributeEditor", -1],
                                                          widthProperty="preferred",
                                                          loadImmediately=True,
                                                          initialWidth=300,
                                                          minimumWidth=300)
        self.raise_()
        
    def populateViewTabs(self):
        modelObj = self.createItemModel("all")
        listViewObj = ListView(isFavoriteIn=False, parentObjIn=self)
        listViewObj.setModel(modelObj)
        self.viewTabs.addTab(listViewObj, "all")

    def createItemModel(self, category):
        toolInfosList = self._helperObj.getToolInfos(category)
        toolInfoModelObj = ItemModel(toolInfosList, self)

        proxyModelObj = ItemProxyModel(self)
        proxyModelObj.setSourceModel(toolInfoModelObj)
        proxyModelObj.setFilterRole(QtCore.Qt.UserRole)
        proxyModelObj.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive)
        proxyModelObj.setSortRole(QtCore.Qt.UserRole)
        proxyModelObj.sort(0)

        return proxyModelObj 

 

0 Likes
Message 5 of 9

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I looked at your top level code but I don't think it is very helpful to reproduce the issue on my side. Please send me a sample could reproduce the issue.

 

Yours,

Li

 

 

0 Likes
Message 6 of 9

Anonymous
Not applicable
I was hoping something would jump at at you in the top level code. I'll
make a reproducible example that I can send as soon as I have time. Thanks.
0 Likes
Message 7 of 9

Anonymous
Not applicable

OK, I have a nice simple case that shows the problem.  There is a zip of a directory containing a python file and a .ui file attached.

 

Here's how to reproduce it:
1) Start up maya 2017

2) In the python script editor, import the python file:

    import toolBrowserWindow_TEST

3) Run the main in that module:
    toolBrowser = toolBrowserWindow_TEST.main()

 

You should now see a 150-item list (Tab name: Tools Browser) with a scroll bar docked at the right side of the screen.  The scroll bar will not respond to clicking or dragging.

 

4) Drag the Tools Browser tab out so it is floating.  Now the scroll bar should work.

5) Re-dock it in the same place and it will not scroll.

 

If you can correct whatever I'm doing wrong, I would appreciate it!

 

Thanks.

 

0 Likes
Message 8 of 9

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

I've just tested it with Maya 2017 Update 4 running on Windows 10. It seems working fine, I could drag the scrollbar as expected. Are you using Maya 2017 with latest update(should be update 5)?

 

Yours,

Li

0 Likes
Message 9 of 9

Anonymous
Not applicable

That was it!


 I was on vanilla no-updates 2017.  I'm on Windows 7, but applying Update 5 (which took a couple of hours) did the trick!

 

 

Thanks, Sumit

0 Likes