Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to match QPushButton size to default plugin toolbar icons using add_plugins_toolbar_widget

New Here ,
May 06, 2025 May 06, 2025

Hello,

I'm developing a custom plugin for Substance 3D Painter version 11.0.1 using the Python API on Windows 11.

Using add_plugins_toolbar_widget(), I successfully added a QPushButton to the plugin toolbar. However, I’m having trouble matching the button’s size to the default plugin toolbar icon buttons (such as the resources-updater icon).

I tried using setFixedSize() to manually set the size, but it doesn’t perfectly match the default icons.

Here is a simplified version of my code:

 

import substance_painter 
from PySide6 import QtWidgets

# Global variable
sample = None

class Button:
    def __init__(self):
        self.initialization()
        
    def initialization(self):
        self.init_widget_button()
        self.show_ui()

    def init_widget_button(self):
        self.button = QtWidgets.QPushButton()
        self.button.setFixedSize(32, 32)

    def show_ui(self):
        substance_painter.ui.add_plugins_toolbar_widget(self.button)

    def cleanup(self):
        if self.button:
            substance_painter.ui.delete_ui_element(self.button)
            self.button = None

def start_plugin():
    global sample
    sample = Button()

def close_plugin():
    global sample
    if sample:
        sample.cleanup()
        sample = None

if __name__ == "__main__":
    start_plugin()

 

Question:
Is there a way to make this QPushButton match the size and look of the built-in plugin toolbar icon buttons?

Any help or guidance would be greatly appreciated.
Thank you in advance!

TOPICS
Discussion , Scripting
84
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

New Here , May 10, 2025 May 10, 2025

Update:
I managed to solve the issue.

Instead of using QPushButton, I used QToolButton, which allowed me to achieve the desired size and appearance matching the default plugin toolbar icons. It worked seamlessly when added via add_plugins_toolbar_widget().

Thank you to everyone who took the time to read my post! I hope this helps anyone facing a similar issue.

Translate
New Here ,
May 10, 2025 May 10, 2025
LATEST

Update:
I managed to solve the issue.

Instead of using QPushButton, I used QToolButton, which allowed me to achieve the desired size and appearance matching the default plugin toolbar icons. It worked seamlessly when added via add_plugins_toolbar_widget().

Thank you to everyone who took the time to read my post! I hope this helps anyone facing a similar issue.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines