Write control properties Qt Designer plugin loaded 1-

I. Introduction

Load the plug-in is the first step in the entire property designer to get through the function, plug-in controls are not loaded, do not get behind do not play can not go on playing, from a dynamic library is loaded out of control, certainly need to reflection, .NET developers have done before when I felt something very strong reflection of this, was able to read out the DLL load control, now use Qt, Qt also found reflection, perhaps this stuff could have major development language platform bar, Qt reflection corresponding class called QMetaObject, really powerful, in fact, the entire Qt development framework is super strong, since I turned Qt development mainly fell in love with her, GUI development framework other cross-platform in front of the platform, will be Qt seconds into the slag, cross-platform Qt is beyond doubt, dozens of megabytes of memory storage space to run, especially in embedded linux this resource rather tense situation, the performance of Qt to play extreme.

Experience Address: https://pan.baidu.com/s/1A5Gd77kExm8Co5ckT51vvQ extraction code: 877p File: An executable file .zip

Second, the effect of FIG.

Three features

  1. All controls automatically load the plug-in generates a list file, the default built-in controls over 120.
  2. To drag the canvas automatically generate the corresponding control, WYSIWYG.
  3. Chinese property right of the bar, change the corresponding property is immediately applied to the corresponding selected control, simple and intuitive, very suitable for white use.
  4. Original text translation attribute field mapping mechanism, high efficiency, you can easily expand the property bar other languages.
  5. Automatically extracting properties of all the controls and properties shown on the right column, including drop-down box enumerated value and the like.
  6. Support manually select the plug-in file import plug-in external files.
  7. All controls current canvas configuration information can be exported to a xml file.
  8. You can manually select the xml file open layout control, automatic load control based on the xml file.
  9. Can pull the slider, check box analog data, text input box, the data application in three ways to generate all of the controls.
  10. Control supports eight directions pulling resize, adaptive to any resolution, right and left can fine-tune the keyboard up and down position.
  11. They opened the serial collection, gathering network, database data set collected in three ways.
  12. Code is very concise, very detailed notes, can be configured as a prototype, develop their own more features.
  13. Written in pure Qt, Qt support any version of the compiler + any + any system.

Fourth, the core code

void frmMain::initPlugin()
{
    //载入默认的插件
#if defined(Q_OS_WIN)
    QString pluginName = QString("%1/quc.dll").arg(qApp->applicationDirPath());
#elif defined(Q_OS_UNIX)
    QString pluginName = QString("%1/libquc.so").arg(qApp->applicationDirPath());
#elif defined(Q_OS_MAC)
    QString pluginName = QString("%1/libquc.dylib").arg(qApp->applicationDirPath());
#endif
    loadPlugin(pluginName);
    //载入默认的控件xml数据
    openFile(qApp->applicationDirPath() + "/quc.xml");

    qApp->processEvents();
    ui->listWidget->verticalScrollBar()->setValue(0);
}

void frmMain::loadPlugin(const QString &fileName)
{
    openPlugin(fileName);
    this->setWindowTitle(QString("自定义控件属性设计器(共 %1 个控件)(QQ:517216493)").arg(ui->listWidget->count()));
}

void frmMain::openPlugin(const QString &fileName)
{
    qDeleteAll(listWidgets);
    listWidgets.clear();
    listNames.clear();
    ui->listWidget->clear();

    //加载自定义控件插件集合信息,包括获得类名+图标
    QPluginLoader loader(fileName);
    if (loader.load()) {
        QObject *plugin = loader.instance();

        //获取插件容器,然后逐个遍历容器找出单个插件
        QDesignerCustomWidgetCollectionInterface *interfaces = qobject_cast<QDesignerCustomWidgetCollectionInterface *>(plugin);
        if (interfaces)  {
            listWidgets = interfaces->customWidgets();
            int count = listWidgets.count();
            for (int i = 0; i < count; i++) {
                QIcon icon = listWidgets.at(i)->icon();
                QString className = listWidgets.at(i)->name();

                QListWidgetItem *item = new QListWidgetItem(ui->listWidget);
                item->setText(className);
                item->setIcon(icon);
                listNames << className;
            }
        }

        //获取所有插件的类名
        const QObjectList objList = plugin->children();
        foreach (QObject *obj, objList) {
            QString className = obj->metaObject()->className();
            //qDebug() << className;
        }
    }
}

Fifth, introduce controls

  1. More than 150 exquisite control, covers a variety of dashboards, progress bar, the progress of the ball, compass, graphs, scales, thermometers, navigation bar, navigation bar, flatui, highlight the button, slide the selector, the lunar calendar and so on. Qwt far more than the number of controls integration.
  2. Each class can be independently as a separate control, zero coupling each control file and a header file to achieve a code amount, independent of other files to facilitate individual control integrated into the project source code form, less. qwt interlocking control class, highly coupled, want to use one of the controls, must contain all the code.
  3. Write all pure Qt, QWidget + QPainter to draw, to support any Qt version Qt4.6 Qt5.12, support for mingw, msvc, gcc compiler, etc., support any operating system such as windows + linux + mac + embedded linux, which does not garbled can be directly integrated into Qt Creator, a built-in controls and use the same, most of the effects can be as long as several properties are set, very convenient.
  4. DEMO separate source containing the control corresponding to each control has a convenient reference. It also provides integrated use of all controls a DEMO.
  5. Source code for each control has detailed Chinese annotation, are prepared in accordance with unified design specifications, easy to learn to write custom controls.
  6. Each control default color and demo corresponding color is very beautiful.
  7. More than 130 visible control, six invisible control.
  8. Portion control provides a variety of styles style selection, multiple choice style indicator.
  9. All controls changes adaptive stretched form.
  10. Integrated design custom attribute that supports drag design, WYSIWYG support the import and export in xml format.
  11. Activex control that comes with demo, all controls can be run directly in the browser ie.
  12. Fontawesome integrated graphics font + Alibaba iconfont collection of hundreds of graphic fonts, font fun graphic brings.
  13. All controls and finally generate a dynamic library files (dll or so, etc.) can be integrated directly into qtcreator designed for use in drag.
  14. Already qml version, the latter will consider a pyqt version, if the user is in great demand then.
  15. Custom plug-in open dynamic library (permanent free), and the back door without any restrictions, ease of use.
  16. 26 now available version dll, which includes qt5.12.3 msvc2017 32 + 64 mingw 32 + 64 in.
  17. From time to time to increase control and improve controls, regularly updated SDK, to welcome all suggestions, thank you!
  18. Qt introductory books recommended Huo Yafei of "Qt Creator Quick Start" "Qt5 programming entry", Qt official Advanced book recommendations "C ++ GUI Qt4 programming."
  19. Highly recommended programmer self-discipline and planning book series "lying programmer" "Programmer's growth course", "grief programmer", benefited from a lifetime!
  20. SDK download link: https://pan.baidu.com/s/1A5Gd77kExm8Co5ckT51vvQ extraction code: 877p
  21. Download link is included in the various versions of the dynamic library files, header files of all the controls, the use of demo, custom controls + properties designer.
  22. widget versions (QQ: 517216493) qml versions (QQ: 373955953) sambong camel (QQ: 278969898).
  23. Qt's advanced column know almost Taoge road https://zhuanlan.zhihu.com/TaoQt
  24. Welcome concern public micro-channel number] [efficient programmers, content C ++ / Python, learning, writing skills, popular technology, career development, a lot of dry goods, benefits a lot!

Guess you like

Origin www.cnblogs.com/feiyangqingyun/p/11489977.html