Copy link to clipboard
Copied
Hello Everyone,
I am writing a C++ plugin using the latest SDK (v1-Aug 2025) for Adobe Illustrator 2025 (version 29.8.1). My requirement is to display a Qt UI inside an AI Panel. I have taken the EmptyPanel sample as a reference and added my Qt widgets to the panel.
I am able to see the Qt widget in the panel, and it resizes when the panel resizes. However, the Qt widget is not fully occupying the panel space, even though I set the widget size to match the AI Panel size using the sAIPanel->GetSize API. I am also updating the size when the window size changes through PanelSizeChangedNotifyProc.
To isolate the issue, I created a simple QWidget and explicitly set its geometry to the panel size, but I still see the same problem.
Below is the code snippet. Also attached the screenshot of my Plugin panel view. Could someone shed some light on what I might be missing or doing wrong?
Thanks in advance!
ASErr EasyVariantsPlugin::StartupPlugin(SPInterfaceMessage* message)
{
//Initialization code
AISize pnSize = { 2000, 2000 };
AIErr error = sAIPanel->Create(fPluginRef, ai::UnicodeString("MyTestPlugin"), ai::UnicodeString("MyTestPlugin"), 1, pnSize, true, NULL, this, fPanel);
AISize minSize = { 200, 200 };
AISize maxSize = { 2000, 2000 };
AISize prefConstSize = { 500, 500 };
AISize prefUnconstSize = { 500, 500 };
error = sAIPanel->SetSizes(fPanel, minSize, prefUnconstSize, prefConstSize, maxSize);
CHECK_ERROR
error = sAIPanel->Show(fPanel, true);
CHECK_ERROR
error = sAIPanel->SetVisibilityChangedNotifyProc(fPanel, PanelVisibilityChangedNotifyProc);
CHECK_ERROR
error = sAIPanel->SetSizeChangedNotifyProc(fPanel, PanelSizeChangedNotifyProc);
CHECK_ERROR
error = sAIPanel->SetClosedNotifyProc(fPanel, PanelClosedNotifyProc);
CHECK_ERROR
AddQtWidgets();
}
AIErr EasyVariantsPlugin::AddQtWidgets()
{
AIErr error = kNoErr;
_hDlg = nullptr;
error = sAIPanel->GetPlatformWindow(fPanel, _hDlg);
if (error != kNoErr || !_hDlg)
return error;
_containerWidget = new QWidget();
_containerWidget->setStyleSheet("background-color: green;");
SetParent((HWND)_containerWidget->winId(), _hDlg);
SetWindowLong((HWND)_containerWidget->winId(), GWL_STYLE, WS_CHILD | WS_VISIBLE);
AISize panelSize = { 0, 0 };
error = sAIPanel->GetSize(fPanel, panelSize);
_containerWidget->setGeometry(0, 0, panelSize.width, panelSize.height);
_containerWidget->show();
return error;
}
Calling below function from "void PanelSizeChangedNotifyProc(AIPanelRef inPanel)" callback
void UpdateUIOnPanelResize(AISize& outSize)
{
if (_containerWidget != nullptr)
{
_containerWidget->setGeometry(0, 0, outSize.width, outSize.height);
}
}
Sorry, I'm not sure I was clear enough. I don't mean a pixel <--> point scaling; all of the panel APIs work in pixels, not points. I can get how that might not be clear given that most of the APIs do work in points. That said, pixels basically equal points for Illustrator.
What I meant was that Illustrator has a UI scaling option (somewhere in preferences) that literally scales the whole application, similar to doing via the OS. It very well might get automatically defaulted to some value based
...Copy link to clipboard
Copied
FIrst thing is to make sure that AI doesn't have any UI scaling going on. If so, you can tell Qt to match the UI scaling (it has a similar feature) and that might solve your problem.
We do exactly what you're doing and I don't see any obivous reason why it wouldn't work at first blush. If you find it's not the scaling, reply and I'll poke around our internals a bit and see if there's something we've got that you're missing.
Copy link to clipboard
Copied
Thank you, A. Patterson, for taking the time to read my lengthy post and respond. Your feedback is greatly appreciated. As you suggested, I attempted to set the scaled value to my QWidget; however, it is still not functioning as expected. I have applied a scale factor of 1.3333f, based on the conversion from points to pixels, but this has not resolved the issue. Could you please advise on how I can adjust the widget so that it occupies the available panel space? Maintaining the aspect ratio is not necessary in this case. My Dev setup details are: Windows 10, VS2022 and Adobe Illustrator 2025.
void UpdateUIOnPanelResize(AISize& outSize){
if (_containerWidget != nullptr){
const float kiUIScaleFactor = 1.3333f;
const int kiNewWidth = outSize.width * kiUIScaleFactor;
const int kiNewHeight = outSize.height * kiUIScaleFactor;
_containerWidget->setGeometry(0, 0, kiNewWidth, kiNewHeight);
}
}
Copy link to clipboard
Copied
Sorry, I'm not sure I was clear enough. I don't mean a pixel <--> point scaling; all of the panel APIs work in pixels, not points. I can get how that might not be clear given that most of the APIs do work in points. That said, pixels basically equal points for Illustrator.
What I meant was that Illustrator has a UI scaling option (somewhere in preferences) that literally scales the whole application, similar to doing via the OS. It very well might get automatically defaulted to some value based on resolution, monitor, etc. If that's set to 1, you shouldn't need to do any scaling. If you _do_ need to scale it, to make things look right you should use the QT scaling options, which are -- if memory serves -- done via environment variables that need to be set before the QApplication is created.
Beyond that though, I feel like the logic is very straight forward for doing what you're doing. The headaches came form it being off by a couple of pixels (due to invisible widget chrome) -- we were never off by as much as your screenshots. Which suggests something important _is_ missing. I'll take a look later this morning and see if I can't spot some factor that's missing from your code.
Copy link to clipboard
Copied
One minor thing: I'd avoid stylesheets unless you absolutely need or want to work with them. They can have unexpected side-effects. Better to set colours by simply setting the background colour directly via QPalette. That's also much more performant. If nothing else, it just removes one potential (if unlikely) cause for your layout problem.
We do use stylesheets in our application, but only for things that you can't set any other way though members or methods directly.
Copy link to clipboard
Copied
Thank you so much for the detailed explanation @A. Patterson . I will try this and make the changes accordingly. Right now, I don't have a bigger monitor to see that option in the preferences (Illustrator's UI scaling options are only available when the monitor resolution is more than 1920x1080 with a scaling of 100%), and I also need to figure out how to fetch the UI scaling value using the Illustrator API. Thanks!
Copy link to clipboard
Copied
Thank you @A. Patterson for the suggestion regarding using stylesheets. I will avoid using stylesheets and start using QPalette instead.
Copy link to clipboard
Copied
Hi @A. Patterson , I need some more help. I am trying to build the same plugin on Mac. I can build it on macOS and resolve the dependencies, but I am not able to see my plugin UI. After the plugin loads, Illustrator does not show any menu bar, and a panel window with a default size stays open. Please refer to the screenshot.
I have modified the Mac-specific code in AddWidgets() as shown below:
#ifdef MAC_ENV
_containerWidget = new TestColorWidget(nullptr);
AISize panelSize = { 0 };
error = sAIPanel->GetSize(fPanel, panelSize);
UpdateUIOnPanelResize(panelSize);
_containerWidget->show();
NSView* qtView = (NSView*)_containerWidget->winId();
[hDlg setFrame:[qtView frame]];
[hDlg addSubview:qtView];
// // Get our own bundle
// NSBundle* bundle = [NSBundle bundleWithIdentifier:@"com.adobe.illustrator.plugins.EmptyPanel"];
// // Load the nib file
// CalcController* calculator = [CalcController alloc];
// [calculator initWithNibName:@"View" bundle:bundle];
// // Set panel to be our nibās view
// NSView* newView = [calculator view];
// [hDlg setFrame:[newView frame]];
// [hDlg addSubview:newView];
#endif
Below are my development environment settings:
MacBook Pro
Chip: Apple M1 Pro
macOS Sequoia 15.6
Xcode 26.0
Adobe Illustrator 2025, Version 29.8.1
Am I missing anything? If I remove my Qt-related code, I can see the EmptyPanel UI without any issues. Thanks in advance!
Copy link to clipboard
Copied
Oh boy. I'm afraid I'm not a Mac guy, I'm a Windows guy. I know our Mac guy has to jump through a bunch of hoops to get this working on OSX.
I took a look, and this is roughly the code we use to glue the Qt Widget to the panel:
class CMacNativeWidget : public QMacNativeWidget {
public:
CMacNativeWidget() : QMacNativeWidget(nullptr) {
setAutoFillBackground(true);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
m_embeddedView = nativeView();
}
NSView* getEmbeddedView() const
{
return m_embeddedView;
}
void resizeEvent(QResizeEvent*)
{
setAttribute(Qt::WA_Mapped);
QMacNativeWidget::resizeEvent(event);
}
void attachPanel(NSView* parent, QWidget* widget)
{
if (nullptr == parent) {
return;
}
widget->setParent(this);
auto* layout = new QVBoxLayout();
layout->setContentsMargins(1, 0, 0, 0);
layout->addWidget(widget);
setLayout(layout);
[parent addSubview:getEmbeddedView()];
}
private:
NSView* m_embeddedView;
};
To use the above code, we do something like this:
CMacNativeWidget* AttachWidgetToPanel(QWidget* widget, void* panelView)
{
if (nullptr == panelView) {
return nullptr;
}
auto nativeWidget = new CMacNativeWidget;
nativeWidget->attachPanel(static_cast<NSView*>(panelView), widget);
nativeWidget->show();
return nativeWidget;
}
Anything beyond this, I doubt I can share, but maybe this will get you over the hump. I know we also have a ton of code dealing with keystrokes & stuff, that's all done via event filters.
Copy link to clipboard
Copied
I should say, in case it's not obvious, that the above code is all Obj-C code, so it ends up in a .mm rather than a .cpp
Copy link to clipboard
Copied
Thank you @A. Patterson , for taking the time to provide the sample code for Mac. Much appreciated.
I have added your code to my codebase and separated it into .h and .mm files. Then I placed the following code in my AddWidgets function.
AIErr EmptyPanelPlugin::AddWidgets()
{
AIErr error = kNoErr;
hDlg = nullptr;
error = sAIPanel->GetPlatformWindow(fPanel, hDlg);
_containerWidget = new TestColorWidget(nullptr);
// _containerWidget->show();
// _containerWidget->setGeometry(0,0, 500, 500);
_macNativeWidget = AttachWidgetToPanel(_containerWidget, hDlg);
AISize panelSize = { 0 };
error = sAIPanel->GetSize(fPanel, panelSize);
panelSize = { 500, 500 };
UpdateUIOnPanelResize(panelSize);
_macNativeWidget->show();
return error;
}
However, the same behavior persists. This time, I am unable to see the blank panel with the default size (600, 600), and Adobe Illustrator is not showing any menu bar. I am also receiving the "PanelSizeChangedNotifyProc" callback but not PanelVisibilityChangedNotifyProc.
Any additional inputs or suggestions would be greatly appreciated to help resolve this issue.
Copy link to clipboard
Copied
Hi @A. Patterson,
I am using Qt 5.15.2, so I modified the code you shared to make it compatible with Qt 5.15.2 as shown below, but I am still seeing the same behavior. I am loading the plugin from the SDK/SampleCode/Output directory by setting the "Additional Plug-ins Folder" in Preferences. I suspect the issue might be related to plugin loading or visibility. Any inputs or suggestions would be greatly appreciated.
#include <Cocoa/Cocoa.h>
#include "PluginUtils.h"
#include <QtWidgets/QVBoxLayout>
#include <objc/objc.h>
#include <objc/message.h>
CMacNativeWidget::CMacNativeWidget(QWidget* child)
:QWidget(nullptr)
{
setAutoFillBackground(true);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
auto layout = new QVBoxLayout();
layout->setContentsMargins(1, 0, 0, 0);
layout->addWidget(child);
setLayout(layout);
}
void CMacNativeWidget::resizeEvent(QResizeEvent* event)
{
NSLog(@"##### CMacNativeWidget::resizeEvent");
setAttribute(Qt::WA_Mapped);
QWidget::resizeEvent(event);
}
void CMacNativeWidget::attachToPanel(void* panelView)
{
NSView* qtNSView = reinterpret_cast<NSView*>(winId());
NSView* parent = reinterpret_cast<NSView*>(panelView);
[parent addSubview:qtNSView];
if ([[panelView subviews] containsObject:qtNSView]) {
NSLog(@"##### Successfully added subview");
} else {
NSLog(@"##### Subview was not added!");
}
}
CMacNativeWidget* AttachWidgetToPanel(QWidget* widget, void* panelView)
{
auto nativeWidget = new CMacNativeWidget(widget);
nativeWidget->attachToPanel(panelView);
nativeWidget->show();
return nativeWidget;
}
Copy link to clipboard
Copied
I'm afraid we're beyond what little I know about this on Mac. The only other thing I can think to try would be making the widget 2x or 3x bigger than you want to make sure it's not hiding behind the AI panel. Maybe z-order is an issue? Beyond that I honestly don't know. We haven't worked with Qt 5.x in about 4 or 5 years
Copy link to clipboard
Copied
Hi @A. Patterson, I have increased the size(Hard-coded to 1500 X 1500) but no luck. I will debug further and update here my solution later. I am also a windows guy. Thank you for the feedback and inputs.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now