Unsolved is there a step by step plugin course?I cannot compile!
-
Hi, guys.
I want to write a plugin, had found this course:https://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html.
but it did not tell how to use the plugin. Here is my test:
1/ install qt-opensource-windows-x86-5.14.1.exe (about 2.2GB)
2/ open qt creator, new->other->qt4 custom plugin, select msvc2017-32bit , build it , so far it's OK.
3/ copy release/xx.dll to d:\Qt\Qt5.14.1\Tools\QtCreator\bin\plugins\designer
Open creator again, i can see the plugin in the custom widget tab.
4/ Now ,new a application project. drag the plugin to mainwindow, build, it says : cannot find xx.h
5/ I copy xx.h to d:\Qt\Qt5.14.1\5.14.1\msvc2017\include\QtGui
Now it can build the app, but link fail, it says:
mainwindow.obj:-1: error: LNK2019: 无法解析的外部符号 "public: __thiscall ArrowNavi::ArrowNavi(class QWidget *,class QPoint,class QPoint)" (??0ArrowNavi@@QAE@PAVQWidget@@VQPoint@@1@Z),该符号在函数 "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QAEXPAVQMainWindow@@@Z) 中被引用So here are the question:
1/ copy xx.dll and xx.h to those folder , am I right?
2/ How can I build the application without LINK2019?Thank you all.
-
@QtTester Do you really want to create a plug-in for QtDesigner?
Or do you mean this: https://doc.qt.io/qt-5/plugins-howto.html ? -
@jsulm still it does not have my answer.
-
@QtTester And you did not answer my question.
-
@QtTester Also there is an example application: https://doc.qt.io/qt-5/qtwidgets-tools-plugandpaint-app-example.html
-
@jsulm
I copy those 5 files: arrownavi.obj/arrownaviplugin.obj/moc_arrownaviplugin.obj/mocarrownavi.obj/qrc_icons.obj to app source AND debug folder , add them to pro, NOW it can be compiled and run! so exciting!
but the resource picture cannot be displayed, do you have any ideas?
any tips will be appreciated! -
@jsulm
I have the similar pulgin requirement. but not the same.
for example , we are 3 people team, A writes voice codec, B writes video codec, C writes gui and integrate all of them to one exe file.
So , voice and video codec can be set to a plug-in widget, and C drug them from qt creator to his mainwindow and build to a single exe file.
Specially , A and B should not expose their source code to each other.
I am not sure it should be called "plugin" ??? -
@QtTester said in is there a step by step plugin course?I cannot compile!:
I am not sure it should be called "plugin" ???
No, it is not.
It sounds more like static linking if you want to have one executable.
It would be easier to use shared libraries, you would then have one executable plus shared libraries. -
@jsulm
Still I need a QPushbutton-like "drag and drop" plug-in.
Today I try these procedure:
1\ add QDESIGNER_WIDGET_EXPORT to the class during plugin,
2\ copy those dll and lib to application's directory "libs", and import them. pro looks like:
LIBS += $$PWD/libs/arrownaviplugin.lib
INCLUDEPATH += $$PWD/libs
DEPENDPATH += $$PWD/libs
3\ remove the objs, this is a stupid choice.
4\ build them , so far it's OK!
5\ Run, but says:
QWidget: Must construct a QApplication before a QWidget
21:36:07: The program has unexpectedly finished.
Why? where I shoud add QApplication? there is a QApp already in the test app. -
already DONE, see
https://www.cnblogs.com/georgeOfChina/p/7773141.html