Skip to main content
Participating Frequently
July 1, 2023

Switching to Bake Mesh Maps mode kills my QtWidget window, any workaround?

  • July 1, 2023
  • 3 replies
  • 515 views

Our studio uses a tool that needs to stay open throughout the entire work session, in fact it has it's own Open Project button that also call a bunch of other functions that load metadata associated with the asset, sets up export paths an so on.  Substance v 9.0 seems to destroy my QT dialog when I go into Bake Mode, which is unacceptable in our current pipeline. Any way to avoid that?

Here is an example of how I create my plugin window:

 

class PluginWidget01(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(PluginWidget01, self).__init__(parent)
        self.init_ui()

    def init_ui(self):
	# UI elemenents here

    # As well as UI functions and connections



class MyPlugin:
    def __init__(self):
        self.widget = PluginWidget01()
        main_window = substance_painter.ui.get_main_window()
        self.dock_widget = QtWidgets.QDockWidget('Exporter 0.1', main_window)
        self.dock_widget.setObjectName('PluginWidget01')
        self.dock_widget.setWidget(self.widget)

        self.dock_widget.setAllowedAreas(QtCore.Qt.TopDockWidgetArea | QtCore.Qt.LeftDockWidgetArea)

        main_window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.dock_widget)

        plugin_widgets.append(self.dock_widget)

def start_plugin():
    close_plugin()
    MyPlugin()

 
Any help would be greatly appreciated

3 replies

Léna Piquet Froyok
Adobe Employee
Adobe Employee
July 13, 2023

How are you building the UI itself ? Do you have any parent/layout widget ?

In my own plugins I use a QtWidgets.QFrame() which doesn't show this issue, so maybe that's what you are missing.

Participating Frequently
July 5, 2023

Hi @Léna Piquet - Froyok 
Thank you for your reply, this is exactly what I've been looking for! Now the UI persists even when switching modes and none of the settings get lost. The reason for Qt API: simple oversight. I was handed a UI template and everything was built on top of it, but it was easy to update as per your recommendation.

One more question, is there a trick to setting UI style policy for my pluggin? It looks different when docked vs floating, and my attemps to force consistent style led to overriding entire Substance UI

 



Léna Piquet Froyok
Adobe Employee
Adobe Employee
July 4, 2023

Hi,

 

Any reasons why you want to create a dock widget with the Qt API direclty instead of using our own API ?

Our API is the recommended way, especially since you can specify in which mode the dock should be visible.

 

Here is an example of a dock widget creation that will appear in both the painting and baking mode

substance_painter.ui.add_dock_widget(
	Widget,
	substance_painter.ui.UIMode.Edition | substance_painter.ui.UIMode.Baking
)

 

When switching modes, we destory and re-create the UI based on a saved configuraiton, so any widgets created outside of this scope maye not behave properly since we can't really be aware of it. Our UI API allows that and help restore properly the docks.