我使用QtInstallerFramework,我试图添加自定义页面时,uninstalling的应用程序.

我有custompage.ui个文件(简单文本),我正在将其添加到我的package.xml中:

<UserInterfaces>
        <UserInterface>custompage.ui</UserInterface>
</UserInterfaces>

这就是我在我的componentscript.js岁时如何使用它:

Component.prototype.componentLoaded = function ()
{
    installer.addWizardPage(component, "CustomPage", QInstaller.ReadyForInstallation)
}

问题是,该页面仅在我安装应用程序时显示.当我卸载它时,CustomPage不显示.

另外,用另一种方法,如果我try 将定制页面添加到我的controlscript.js中,如下所示:

Controller.prototype.ReadyForInstallationPageCallback = function ()
{
    try {
        installer.addWizardPage(component, "CustomPage", QInstaller.ReadyForInstallation);
    }
    catch (e) {
        QMessageBox.warning("QMessageBox", "", e, QMessageBox.Ok);
    }
}

我收到以下错误:

ReferenceError: component is not defined

So, it looks like the component is not loaded at all when the application is uninstalled.
And from Qt documentation we can add custom pages only in components xml file with <UserInterfaces> tag.
Does this mean that we can not use custom gui pages in the uninstaller or I am missing something?

推荐答案

During installation, package.xml and componentscript.js are in full effect, allowing for dynamic addition of wizard pages.
However, during uninstallation, the framework does not process component scripts in the same manner, which is why you see that custom pages do not appear.

[Installer/Uninstaller Process]
┌────────────────────┐   ┌──────────────────────────┐   ┌─────────────────────────┐
│ package.xml        │   │ componentscript.js       │   │ installscript.qs        │
│  └─ UserInterfaces │──►│  └─ addWizardPage(...)   │──►│  └─ Conditionall        │
└────────────────────┘   └──────────────────────────┘   │    modify wizard        │
            │                              ▲            └─────────────────────────┘
            │                              │                        ▲
            └──────────────────────────────┘                        │
                         Installation Process                       │
                                                            Uninstallation Process

You should use installscript.qs to inject custom logic that runs during both installation and uninstallation (as in this example).
Since this script is executed in both contexts, it is the ideal place to conditionally apply modifications for the uninstallation process.
It can distinguish between installation and uninstallation through conditional checks, enabling specific actions during the uninstallation phase.

使用installer.isUninstaller()确定卸载过程是否正在进行,然后继续执行用于添加或修改向导页的自定义逻辑.

You can add custom pages through installer.addWizardPage for the installation process.
For uninstallation, consider modifying existing pages or using available hooks in installscript.qs to interact with the uninstallation process.

installscript.qs年中:

function Controller() {
    // Constructor for script
}

Controller.prototype.IntroductionPageCallback = function() {
    if (installer.isUninstaller()) {
        // Custom logic for uninstallation, e.g., modifying the Introduction page
    }
}

因此,我唯一的 Select 是修改现有页面(可能访问gui.currentPageWidget()),并在该页面对象中添加/删除属性/对象.

是的,大概是这样的:

function Controller() {
}

Controller.prototype.IntroductionPageCallback = function() {
    if (installer.isUninstaller()) {
        // Access the current page displayed in the uninstaller wizard
        var currentPage = gui.currentPageWidget();
        
        if (currentPage) {
            // Example modification: Change a label text on the current page
            // Note: That requires knowing the specific object names and structure of the UI
            if (currentPage.findChild("QLabel", "YourLabelObjectName")) {
                currentPage.findChild("QLabel", "YourLabelObjectName").text = "Custom text for the uninstallation process";
            }

            // Example: Adjust visibility of a specific element based on a condition
            var specificCondition = true; // Replace this with your actual condition
            if (specificCondition && currentPage.findChild("QWidget", "YourWidgetObjectName")) {
                currentPage.findChild("QWidget", "YourWidgetObjectName").visible = false;
            }
        }
    }
}

Javascript相关问答推荐

在JavaScript中检索一些文本

Vega中的模运算符

useNavigation更改URL,但不呈现或显示组件

Redux查询多个数据库Api reducerPath&

未捕获错误:[]:getActivePinia()被调用,但没有活动Pinia.🍍""在调用app.use(pinia)之前,您是否try 使用store ?""

将本机导航路由react 到导航栏中未列出的屏幕?

Websocket错误—有一个或多个保留位开启:reserved1 = 1,reserved2 = 0,reserved3 = 0

编剧如何获得一个div内的所有链接,然后判断每个链接是否都会得到200?

React.Development.js和未捕获的ReferenceError:未定义useState

如何发送从REST Api收到的PNG数据响应

确保函数签名中的类型安全:匹配值

将多个文本框中的输出合并到一个文本框中

如何组合Multer上传?

bootstrap S JS赢得了REACT中的函数/加载

为什么这个最小Angular 的Licial.dev设置不起作用?

更改管线时不渲染组件的react

当达到高度限制时,如何裁剪图像?使用html和css

在Reaction Native中,ScrolltoIndex在结束时不一致地返回到索引0

Playwright:ReferenceError:browserContext未定义

如何在底部重叠多个div?