1.打开QT示例,Custom Widget Plugin Example 2.选择编译环境,注意需要与QT creator保持一致,可以通过Help->About Qt Creator里查看qt creator的编译环境,我这里是Qt 6.2.3(MSVC 2019,64 bit) 3.选择release构建 4.将生成的customwidgetplugin.dll放到qtcreator的plugins目录,我的是(D:\software\qt\Tools\QtCreator...
1. 继承QObject和QDesignerCustomWidgetInterface实现插件类(或继承QObject和QDesignerCustomWidgetCollectionInterface实现多个自定义控件); 2. 编写Qt平台无关的工程文件.pro(例如CustomWidgetPlugin.pro); 3. qmake CustomWidgetPlugin.pro; 4. make(windows下vc平台使用nmake,如果发现缺少环境变量,可以运行其bin/vcvars32...
voidCustomWidget2::paintEvent(QPaintEvent*event){QPainterpainter(this);QRecttemp_rect=rect();painter.setPen(Qt::blue);painter.drawText(rect(),Qt::AlignCenter,"this is test custom widget");} 编译好之后,copy dll文件plugin目录,并把所有的designer关闭 我们重新打开designer,并新建一个窗口,看到的效果...
9. 打开customwidget1plugin.cpp,在name()函数中返回的字符串表示该自定义插件名称,这里默认设为”CustomWidget1”;在group()函数中返回的字符创表示自定义插件在设计器中属于哪个分组,如Qt Creator中有Buttons,DisplayWidgets等分组,这里设为MyWidgets;domXml()函数返回的字符串是使用该插件时设计器自动生成的UI文件...
// 控件的名字,注意这里的名字必须和class name保持一致QStringCustomWidget2Plugin::name()const{returnQLatin1String("CustomWidget2");}// 控件分类的名字QStringCustomWidget2Plugin::group()const{returnQLatin1String("");}// 自定义的iconQIconCustomWidget2Plugin::icon()const{returnQIcon();}...
How to Create Qt Plugins》和《Custom Widget Plugin Example》 Qt 提供两种设计插件的API,可以扩展Qt的功能:1)高级API用于设计插件以扩展Qt的功能,例如定制数据库驱动,图像格式,定制样式等;2)低级API用于创建插件以扩展自己编写应用程序的功能,例如将自定义的Widget组件安装到Designer里面,用于界面设计,或者将自定义...
为了让自定义部件在Qt Designer有特殊行为,提供 initialize()函数来配置窗口部件运行过程中的特定行为。该函数在被第一次调用之前先调用createWidget(),可以设定一个内部标志来测试什么时候调用createWidget()函数。 1.构建插件 为了简单期间,这里只提供QLed的源码,customwidgetplugin的源码可在安装目录中的Demo里面查找(...
对于自定义Qt控件插件,Qt已经提供了QDesignerCustomWidgetInterface接口类,我们只需要继承这个类并实现其纯虚函数即可。 cpp #include <QDesignerCustomWidgetInterface> class MyCustomWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface { Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) #...
Qt Designer's plugin-based architecture allows user-defined and third party custom widgets to be edited just like you do with standard Qt widgets. All of the custom widget's features are made available to Qt Designer, including widget properties, signals, and slots. Since Qt Designer uses ...
关键词:Qt5、IconEditor、custom plugin、QtCreator、Failed Plugins、自定义插件 今天,《C++ GUI Programming with Qt 4》看到了第五章自定义IconEditorPlugin的地方。动手尝试过程中,遇到一些问题,记录一下,借前辈之成果,示于后来者。 开发环境:Win7 64 bit + Qt 5.1.0。