I have developed a GUI in Qt as a "Qt GUI Application' in which I have created a QWidget. The UI design (both static and dynamic) is ready in this QtCreator's project.
This project has a ".ui" file, which the QtCreator translates to a ".h" during compile time.
I want to use this UI for my plugin. My plugin interface is a panel.
Can I make the QtProject as library project which includes all required Qt libraries within and use this library in my plugin ?
Or is there any other way to keep the UI (may be a static lib) and the plugin (.aip = dll) be kept totally separate.
Basically what I am searching a way to use the cababilities of QtCreator + visual studio both to generated a Qt based panel plugin for Ai . And now I have no idea of either.
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Sorry, you don't exec(), that's why. You just need to
create
a QApplication (or derived class). For the UI to work, there just has to
be
a QApplication running somewhere. In a standard Qt application, you'd call need to call exec() to start the message loop, but in a plugin there's already a message loop in Illustrator. So long as a QApplication exists, when you call exec() on something like a dialog, it'll work.
I have developed a GUI in Qt as a "Qt GUI Application' in which I have created a QWidget. The UI design (both static and dynamic) is ready in this QtCreator's project.
This project has a ".ui" file, which the QtCreator translates to a ".h" during compile time.
I want to use this UI for my plugin. My plugin interface is a panel.
Can I make the QtProject as library project which includes all required Qt libraries within and use this library in my plugin ?
Or is there any other way to keep the UI (may be a static lib) and the plugin (.aip = dll) be kept totally separate.
|
We use the generated project as our plugin, so yes, you can do this. We find it much easier this way. If you read the qmake documentation, you can find out how to change the extension of the plugin to .aip and (I think its the same configuration option) control the output destination (makes debugging easier).
You could also have this generate a static lib if you wanted probably, but its up to you.
Also,
sAiPanel->GetPlatformWindow() will give me the HWND for windows.
How can I embed the QWidget on this panel ??
Basically what I am searching a way to use the cababilities of QtCreator + visual studio both to generated a Qt based panel plugin for Ai . And now I have no idea of either.
Please help me get started.
|
I reccommend you use either Visual Studio or QtCreator and not both. Either is probably fine. We use Visual Studio, but maybe Creator is better, I don't know (don't have much experience there).
As for using the .ui you created, you'll find some good examples in the documentation, but it basically boils down to this:
Create a class like this:
#include "ui_name_of_ui_file.h" // this is generated when you compile a .ui file
class CMyDialog : public Ui::name_class_in_ui_file {
CMyDialog() { setupUi(this); }
}
setupUi(this) basically creates all the widgets, etc. so that all the members you're inheriting from your ui class actually exist. After that, it's just like any other class. If it's a dialog, call exec() to show it, and start implementing all your dialog functionality.
Adding it to a panel is a little trickier. On Windows, look for QWinWidget. I believe you create a QWinWidget and give it the result of GetPlatformWindow. This basically creates a QWidget that represents the handle you pass it, so that widget is now the panel frame. You'd then parent your panel widget (defined in the .ui file) off of that QWinWidget and it *should* be in your panel in Illlustrator. Lots of little details after that (you'll probably want to connect resizing the panel to resizing your widget, etc.) but that's the gist.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
I did a little checking and it sounds like Qt5 broke QWinWidget. If you're looking to do Qt I'd go with Qt 4.8.x. We're using 4.8.4 at the moment. It sounds like we'll have some work to do to get our stuff going in Qt5.
QWinWidget is found in Qt Solutions, specific qtwinmigrate. You can find that here:
https://qt.gitorious.org/qt-solutions/qt-solutions/source/80592b0e7145fb876ea0e84a6e3dadfd5f7481b6:q...
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Now here's my plan to deal things in short time:
My current state :
1. I have created UI in Qt editor's designer and get a ".ui" file.
2. Compiled it (or atleast run the uic.exe part to translate the .ui file to a .h file)
3. Included this .h file which has all the c++ code of creating and displaying all the widgets which I had selected in the Qt designer. I will include this file in a VS2010 AI-plugin project.
4. In the visual studio's AI plugin project - created object of this UI class (defined in the .h) and added it on the plugin's panel using QWidget and GetPlatformWindow()
The way I have added the code to embed my Qt UI is:
AIPanelPlatformWindow panelPlatfromWindow = NULL;
sAIPanel->GetPlatformWindow(pluginObj->_Panel, panelPlatfromWindow);
int argc = 0;
_Application = new QApplication(argc, 0, true); //Application is object of QApplication
QWidget* parentWidget = new QWidget();
parentWidget->move(0, 0);
Ui::myCustomWidgetUI* widget = new Ui::myCustomWidgetUI;
widget->setupUi(parentWidget);
SetWindowLong((HWND)parentWidget->winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
SetParent((HWND)parentWidget->winId(), panelPlatfromWindow);
parentWidget->show();
SetPropA((HWND)(panelPlatfromWindow), "PANEL", pluginObj);
pluginObj->DefaultWindProc = reinterpret_cast<WNDPROC>(SetWindowLongPtr((HWND)(panelPlatfromWindow), GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(NewWindowProc)));
The UI is visible on the panel, the tab control works but the buttons on the tab do not responding.
My problem:
I have set the windows proc using "SetWindowLongPtr" for my main panel platform (HWND) to point to my handler method (NewWindowProc)
However, I could not get events windows msgs for button clicks, etc.
What have I missed out here ?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
I use the QWinWidget now. But still my SLOT - method is never invoked.
bool isConnected = QObject::connect(widgetUI->btnFindText,
SIGNAL
(clicked()), pluginObj->_UIController,
SLOT
(FindBtnClicked()));
The value of
isConnect
is true after execution of this line. However, the slot - FindBtnClicked is never executed (I placed a break point and a messagebox there).
As we are developing this UI for AI-plugin, our QApplication::exec() do not execute on the main thread. I have spawned a new thread on which I create QApplication, add QWidgets and then run the QApplication::exec(). I spawn this thread at "Start-up" notification of the plugin.
I call QApplication::exit() at "Shut-down" notifcation.
To summarize ;
1. Startup
a. Create "AiPanel", add menu entry etc on the main thread.
b. Spawn a new thread which will create QApplication, add QWidgets and then run the QApplication::exec().
c. In the child thread before QApplication::exec() , I connect the signal and the slot.
2. At Shutdown
a. QApplication::exit().
Is something wrong in this mechanism. Any guess why the slot is not hit. How do you guys handle UI in Qt + plugin ???
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Yes, you don't create any additional threads. QApplication goes on the main thread. Using other threads is fine, but not for Qt. It integrates with the existing event loops, it doesn't stand outside of them on another thread.
We create our QApplication derived class in response to the Startup Plugin message and destroy it in the Shutdown Plugin message. I should mention that we also prevent our plugin from being unloaded by calling AcquirePlugin() and then calling ReleasePlugin at shutdown. If you don't do this, you get all sorts of headaches with virtual tables and such.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Sorry, you don't exec(), that's why. You just need to
create
a QApplication (or derived class). For the UI to work, there just has to
be
a QApplication running somewhere. In a standard Qt application, you'd call need to call exec() to start the message loop, but in a plugin there's already a message loop in Illustrator. So long as a QApplication exists, when you call exec() on something like a dialog, it'll work.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Anytime, glad it's working!
Like I've said before, once you get it up and going, you can do quite a lot, but there will also be quite a lot of little stuff to learn how to override and/or fix. I'd list what we do except your needs will be different from ours I imagine
Anyways, if you have trouble with something, give a shout, we've done a lot with Qt in this context so we can hopefully lend a hand.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more