Qt Creator plugin动手实践(1)学习基本构成

简介: Qt Creator plugin动手实践(1)学习基本构成

Qt Creator plugin


如果把D:\Qt\Qt5.9.8\Tools\QtCreator\lib\qtcreator\plugins\路径下的文件全部删除(只保留Core4.dll文件),然后再启动,那么Qt Creator就变成这样了,简直就是个空壳子:

image.png


image.png


image.png



image.png


可见Qt Creator这个庞然大物是由各类插件构成的!把插件拿掉,它就只是一张皮了。


官网下载:


http://download.qt.io/official_releases/qtcreator/


https://github.com/qt

https://github.com/qt-creator/qt-creator

https://github.com/qt-creator/qt-creator/tree/master/src/plugins/helloworld



官网文档:


https://doc.qt.io/qtcreator/index.html


https://doc-snapshots.qt.io/qtcreator-extending/first-plugin.html



网络教程:

https://www.devbean.net/2012/03/qtcreator-plugin-develop-catalog/ Qt Creator 插件开发,翻译自<Writing-Qt-Creator-Plugins.pdf>

https://www.devbean.net/category/qt-creator-%E6%BA%90%E7%A0%81%E5%AD%A6%E4%B9%A0/ Qt Creator 源码学习



开源项目参考:

https://github.com/lexxmark/QtCreator-JsExtensions-Plugin

https://github.com/pasccom/QtcDevPlugin

https://github.com/MichaelSp/QtCreator-Jenkins-Plugin


https://github.com/Eaknyt/QtCreator-ColorPickerPlugin



Qt5:


qtdesigner的源码在Qt Creator源码里面,以插件形式出现


https://github.com/qt-creator/qt-creator/tree/master/src/plugins/designer



Qt4:

Qt Creator源码里面是没有设计器的实际的代码的,它使用的是QtDesigner.dll。

qtdesigner的源码在qtsdk中。

以qt4.8源码为例:qtdesigner.dll的源码路径为\tools\designer\src


https://github.com/qt/qt/tree/4.8/tools/designer



个人笔记:2019/4/19,摘录于Qt Creator源码

projectexplorericons.cpp //ico文件定义
D:\temp\qt-creator-opensource-src-4.8.2\src\plugins\projectexplorer\projectexplorer.cpp
bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error)
// run icon
const QIcon runSideBarIcon = Utils::Icon::sideBarIcon(Icons::RUN, Icons::RUN_FLAT);
    const QIcon runIcon = Utils::Icon::combinedIcon({Utils::Icons::RUN_SMALL.icon(),
                                                     runSideBarIcon});
    runMenu->menu()->setIcon(runIcon);
    runMenu->menu()->setTitle(tr("Run"));
    msubProjectContextMenu->addMenu(runMenu, ProjectExplorer::Constants::G_PROJECT_RUN);
// run action
    dd->m_runAction = new QAction(runIcon, tr("Run"), this);
    cmd = ActionManager::registerAction(dd->m_runAction, Constants::RUN);
    cmd->setAttribute(Command::CA_UpdateText);
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+R")));
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
    ModeManager::addAction(cmd->action(), Constants::P_ACTION_RUN);
// build session action
    const QIcon sideBarIcon = Utils::Icon::sideBarIcon(Icons::BUILD, Icons::BUILD_FLAT);
    const QIcon buildIcon = Utils::Icon::combinedIcon({Icons::BUILD_SMALL.icon(), sideBarIcon});
    dd->m_buildSessionAction = new QAction(buildIcon, tr("Build All"), this);
// build action
    dd->m_buildAction = new Utils::ParameterAction(tr("Build Project"), tr("Build Project \"%1\""),
                                                     Utils::ParameterAction::AlwaysEnabled, this);
    dd->m_buildAction->setIcon(buildIcon);
    cmd = ActionManager::registerAction(dd->m_buildAction, Constants::BUILD);
    cmd->setAttribute(Command::CA_UpdateText);
    cmd->setDescription(dd->m_buildAction->text());
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+B")));
    mbuild->addAction(cmd, Constants::G_BUILD_BUILD);
// Run without deployment action
    dd->m_runWithoutDeployAction = new QAction(tr("Run Without Deployment"), this);
    cmd = ActionManager::registerAction(dd->m_runWithoutDeployAction, Constants::RUNWITHOUTDEPLOY);
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
 dd->m_runActionContextMenu = new QAction(runIcon, tr("Run"), this);
    cmd = ActionManager::registerAction(dd->m_runActionContextMenu, Constants::RUNCONTEXTMENU, projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
//左边栏按钮
ModeManager::addAction(dd->m_modeBarBuildAction, Constants::P_ACTION_BUILDPROJECT); //Build
ModeManager::addAction(cmd->action(), Constants::P_ACTION_RUN); //Run
ModeManager::addAction(&m_visibleStartAction, Constants::P_ACTION_DEBUG); //Debug
connect(dd->m_runAction, &QAction::triggered,
            dd, []() { m_instance->runStartupProject(Constants::NORMAL_RUN_MODE); });
connect(dd->m_runWithoutDeployAction, &QAction::triggered,
            dd, []() { m_instance->runStartupProject(Constants::NORMAL_RUN_MODE, true); });
D:\temp\qt-creator-opensource-src-4.8.2\src\plugins\debugger\debuggerplugin.cpp
connect(&m_debugWithoutDeployAction, &QAction::triggered, this, [] {
        ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, true);
    });
void ProjectExplorerPluginPrivate::updateRunWithoutDeployMenu()
{
    m_runWithoutDeployAction->setVisible(m_projectExplorerSettings.deployBeforeRun);
}
connect(this, &ProjectExplorerPlugin::updateRunActions,
            dd, &ProjectExplorerPluginPrivate::slotUpdateRunActions);
void ProjectExplorerPluginPrivate::slotUpdateRunActions()
{
    QString whyNot;
    const bool state = ProjectExplorerPlugin::canRunStartupProject(Constants::NORMAL_RUN_MODE, &whyNot);
    m_runAction->setEnabled(state);
    m_runAction->setToolTip(whyNot);
    m_runWithoutDeployAction->setEnabled(state);
}
void DebuggerPluginPrivate::updateDebugWithoutDeployMenu()
{
    const bool state = ProjectExplorerPlugin::projectExplorerSettings().deployBeforeRun;
    m_debugWithoutDeployAction.setVisible(state);
}
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
            this, &DebuggerPluginPrivate::updatePresetState);
void DebuggerPluginPrivate::updatePresetState()
{
    if (m_shuttingDown)
        return;
    Project *startupProject = SessionManager::startupProject();
    RunConfiguration *startupRunConfig = RunConfiguration::startupRunConfiguration();
    DebuggerEngine *currentEngine = EngineManager::currentEngine();
    QString whyNot;
    const bool canRun =
            ProjectExplorerPlugin::canRunStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, &whyNot);
    m_debugWithoutDeployAction.setEnabled(canRun);
}
D:\temp\qt-creator-opensource-src-4.8.2\src\plugins\debugger\images\debugger_continue@2x.png
D:\temp\qt-creator-opensource-src-4.8.2\src\plugins\debugger\images\mode_debug_mask@2x.png
D:\temp\qt-creator-opensource-src-4.8.2\src\plugins\welcome\images\mode_welcome_mask@2x.png
D:\temp\qt-creator-opensource-src-4.8.2\src\plugins\projectexplorer\images\run.png
D:\temp\qt-creator-opensource-src-4.8.2\src\plugins\projectexplorer\images\desktopdevice.png
D:\temp\qt-creator-opensource-src-4.8.2\src\plugins\projectexplorer\images\BuildSettings.png
D:\temp\qt-creator-opensource-src-4.8.2\src\plugins\projectexplorer\images\debugger_start@2x.png
相关文章
|
6月前
|
定位技术 Go 开发工具
dynamic-situational-awareness-qt学习记录
本文是作者yantuguiguziPGJ关于dynamic-situational-awareness-qt学习记录的分享,介绍了在Qt学习过程中发现的qml资源丰富的代码仓库,并提供了资源路径和相关的安装、配置步骤,涉及的内容有数字地球、GIS纹理等,同时提供了相关链接和git命令来克隆代码仓库和ArcGIS Runtime SDK for Qt的安装说明。
|
6月前
|
编解码 开发工具 UED
QT Widgets模块源码解析与实践
【9月更文挑战第20天】Qt Widgets 模块是 Qt 开发中至关重要的部分,提供了丰富的 GUI 组件,如按钮、文本框等,并支持布局管理、事件处理和窗口管理。这些组件基于信号与槽机制,实现灵活交互。通过对源码的解析及实践应用,可深入了解其类结构、布局管理和事件处理机制,掌握创建复杂 UI 界面的方法,提升开发效率和用户体验。
278 13
|
6月前
|
IDE 开发工具 C++
qt creator + vs2019编译记录
本文记录了作者在使用qt creator和vs2019编译项目时遇到的困难和解决方案,包括编译环境设置、qt creator编译脚本的成功案例、不带Ninja的编译脚本问题、错误示范以及相关参考链接。
174 0
qt creator + vs2019编译记录
|
7月前
|
C++ Windows
vs2019 This application failed to start because it could not find or load the QT platform plugin
这篇文章介绍了在VS2019中解决QT程序运行时出现的“无法找到或加载QT平台插件”错误的步骤,通过将必要的DLL文件和插件目录复制到项目解决方案中解决了问题。
|
9月前
Qt安装之后添加或移除组件(Qt Creator 10.0.1)
Qt安装之后添加或移除组件(Qt Creator 10.0.1)
452 2
|
9月前
Qt之HelloWord(Qt Creator 10)
Qt之HelloWord(Qt Creator 10)
|
9月前
|
IDE 开发工具 数据安全/隐私保护
【干货】Qt Creator快速下载、安装、使用教程
【干货】Qt Creator快速下载、安装、使用教程
|
9月前
|
C++
使用Qt Creator 出现的一些错误
使用Qt Creator 出现的一些错误
137 1
|
8月前
|
C++
Qt中的信号与槽如何学习?(包括自定义信号)这篇文章告诉你
以现实中的事件来举例的话,例如有两把不同颜色的信号枪,分别是红色,绿色,打响不通颜色的信号枪会触发不同的槽发生,比如说打响红色这个人就跑步,绿色就走步,但是还有一个很重要的机制,那就是连接,我们需要把信号枪去跟这个人的动作连接起来。 如果上面理解没问题的话我们可以把信号和槽看成两个工具,我们最重要的是如何去把这两个工具连接起来。 它的作用可以让我们更加灵活的去使用不同窗口间的切换以及某些事件的连接。
137 0
|
8月前
|
开发者
Qt中的事件该如何学习?(附带案例)
事件是Qt中比较重要的一部分,在初期如果理解不当学习可能会比较困难,这里提一嘴当初教我的那位老师水平是真的高,让我很轻易的就理解了事件的概念。 在平时我们见到那些界面上的某些快捷键就有可能是事件做的,例如ESC关闭窗口,Enter提交或者登录这种类似的,这也是事件的强大之处。
178 0