Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

IFW: "Critical: Error: Unknown method return type: QList<QJSValue>" when trying to call "findChildren".



  • Re: Qt Installer framework hide or disable buttons

    I tried to hide some button, but I could not get reference to any button.
    So, I tried to get all children by doing:

    var children = gui.findChildren(widget, "*");
    

    then I got

    Critical: Error: Unknown method return type: QList<QJSValue>
    

    Is there any function to get reference to Buttons?

    Qt: 5.11.x
    IFW: 3.0.4

    Regards.


  • Moderators

    Hi @kuro,

    This sounds like a bug somewhere as the code looks correct. Can you provide a complete script that can be used to reproduce this?



  • I'm sorry about I barely can provide only control script( other installer source files contains our product's information).
    It may be hard to use for reproduce, but for your information, attached is (almost) unmodified control script.
    [0_1540106552771_control.js](Uploading 100%)
    (I could not upload the file, so I embed script...and, sorry about Japanese texts..)

    
    function Controller()
    {
      // installer.setDefaultPageVisible(QInstaller.Introduction, false);
      // installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
      // installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
      // installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);
      // if (systemInfo.productType === "windows")
      //   installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
      // installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
      // installer.setDefaultPageVisible(QInstaller.PerformInstallation, false);
      // installer.setDefaultPageVisible(QInstaller.InstallationFinished, false);
      //
      console.log('Controller()');
      this.numUpdates = 0;
      this.componentVersion = "";
      // 自動アップデートの際、終了時にダイアログを表示しておく場合は true にする。
      //  (表示が現状見苦しい形になっているので、一旦 false にしておく
      //   Button関連の制御が可能になったら考える)
      Controller.keepDialogOnUpdate = false;
      //  installer.autoAcceptMessageBoxes();
      installer.componentAdded.connect(this, Controller.prototype.componentAdded);
      installer.finishUpdaterComponentsReset.connect(this, Controller.prototype.finishUpdaterComponentsReset);
      installer.updaterComponentsAdded.connect(this, Controller.prototype.updaterComponentsAdded);
      installer.statusChanged.connect(this, Controller.prototype.statusChanged);
      installer.installationFinished.connect(this, Controller.prototype.installationFinished);
      installer.updateFinished.connect(this, Controller.prototype.updateFinished);
    
      // for all users.
      installer.setValue("AllUsers", "true");
      // Windows版のインストール場所を修正
      if (installer.value("os") === "win") {
        // console.log("os is win, setting TargetDir to ApplicationDirX64");
        // installer.setValue("TargetDir", installer.value("ApplicationsDirX64") + "\\" + installer.value("ProductName"));
        console.log("new TargetDir: " + installer.value("TargetDir"));
      } else {
        installer.setValue("TargetDir", "/Applications/@ProductName@");
      }
    }
    
    Controller.prototype.statusChanged = function(status) {
      console.log("statusChanged: ");
      console.log(status);
      if (installer.isUpdater() && installer.value("silent") === "true") {
        // エラーのとき終了
        if (status === 1) {
          console.log("Error, quit immediately.");
          gui.reject();
        }
      }
    };
    
    function getAppPid(apppath) {
      var pss = installer.execute("/bin/ps", [ "-ax" ]);
      if (pss.length > 1) {
        var lines = pss[0].split("\n");
        for (var i in lines) {
          var m = /[ \t]*([0-9]+)[^\/]+(\/.+)$/.exec(lines[i]);
          if (m) {
    	if (m[2].indexOf(apppath) == 0) {
    	  return parseInt(m[1], 10);
    	}
          }
        }
      }
      return -1;
    }
    
    function killPid (pid) {
      var r = installer.execute("/bin/kill", [ "" + pid ]);
    }
    
    function toVersionNumber(versionString)
    {
      var versions = ["0", "0", "0" ];
      try {
        versions = versionString.split(".");
      } catch (e) {}
      var versionNum = parseInt(versions[0]) * 100 + parseInt(versions[1]) * 10 + parseInt(versions[2]);
      return versionNum;
    }
    
    Controller.prototype.updaterComponentsAdded = function(component) {
      console.log("updaterComponentsAdded");
      Controller.componentVersion = component.value("Version");
      console.log("   component.Version: " + Controller.componentVersion);
    
      this.numUpdates++;
    };
    
    Controller.prototype.finishUpdaterComponentsReset = function(componentsWithUpdates) {
      console.log("finishUpdaterComponentsReset  " + this.numUpdates);
      if (this.numUpdates === 0) {
        if (installer.value("silent") === "true") {
        } else {
          QMessageBox.information("updator.finishing", "アップデート", "アップデートはありません", QMessageBox.OK);
        }
        gui.reject();
      }
    };
    
    Controller.prototype.componentAdded = function (c) {
      console.log("ComponentAdded");
      console.log(c);
      Controller.componentVersion = c.value("Version");
      console.log("   version: " + Controller.componentVersion);
      
      this.numUpdates ++;
    };
    
    Controller.prototype.installerLoaded = function() {
    };
    
    Controller.prototype.IntroductionPageCallback = function() {
      if (installer.isInstaller()) {
        console.log("IntroductionPageCallback");
        // console.log("testvalue: " + installer.value("testvalue"));
        //  build.sh から呼び出された場合(配布用zipを作成中)
    //    var tgtdir = installer.value('BuildTargetDir');
    //    console.log("BuildTargetDir: " + tgtdir);
        //    installer.setValue('TargetDir', tgtdir);
        if (systemInfo.productType === "windows")  {
          var maintenanceToolPath = installer.value("TargetDir") + "\\" + installer.value("ProductName") +"MaintenanceTool.exe";
          if (installer.fileExists(maintenanceToolPath)) {
    	console.log(maintenanceToolPath + " already exists");
    	//
    	var programExecutable = installer.value("TargetDir") + "\\" + installer.value("ProductName") +".exe";
    	if (installer.fileExists(programExecutable)) {
    	  // check version of executable
    	  var arrResult = installer.execute(programExecutable, [ "-v" ]);
    	  console.log("version number of executable: " + arrResult[0]);
    	  var versionNum = toVersionNumber(arrResult[0]);
    	  // check minimum version number that has registry function.
    	  console.log("versionNum=" + versionNum);
    	  if (versionNum > 25) {
    	    console.log("can run registry function from application executable");
    	    arrResult = installer.execute(programExecutable, [ "-c" ]);
    	    console.log("result: " + arrResult[0]);
    	    if (arrResult[0] == "no") {
    	      console.log("No proper Resistry found though already installed");
    	      installer.gainAdminRights();
    	      installer.execute(programExecutable, [ "-i" ]);
    	    }
    	  }
    	  // 起動中のアプリ終了
    	  installer.killProcess(programExecutable);
    	}
    	installer.gainAdminRights();
    	// maintenanceTool起動
    	installer.execute(maintenanceToolPath, ["--updater", "silent=true"]);
    	gui.clickButton(buttons.CancelButton);
    	return;
          } else {
    	console.log(maintenanceToolPath + " not exists.");
          }
        }
        if (systemInfo.productType === "osx")  {
          var programExecutable = installer.value("TargetDir") + "/" + installer.value("ProductName") +".app/Contents/MacOS/" + installer.value("ProductName");
          // 起動中のアプリ終了
          //   macosでは installer.killProcessは機能しない(実装が空)。
          var pid = getAppPid(programExecutable);
          console.log("pid(" + programExecutable + "): " + pid);
          if (pid > 0) {
    	killPid(pid);
          }
          console.log("programExecutable: " + programExecutable);
        }
        // 強制的に「次へ」ボタンを押す
        gui.clickButton(buttons.NextButton);
      } else if (installer.isUpdater()) {
        // アプリケーションから自動アップデート機能として起動された
        if (installer.value("silent") === "true") {
          gui.clickButton(buttons.NextButton);
        }
      }
    };
    
    Controller.prototype.TargetDirectoryPageCallback = function() {
      console.log("ProductVersion: " + installer.value("ProductVersion"));
      console.log("TargetDirectoryPageCallback");
      console.log("InstallDirPath: " + installer.value("InstallerDirPath"));
      console.log("TargetDir: " + installer.value("TargetDir"));
      console.log("ApplicationsDir: " + installer.value("ApplicationsDir"));
      console.log("ApplicationsDirX86: " + installer.value("ApplicationsDirX86"));
      console.log("ApplicationsDirX64: " + installer.value("ApplicationsDirX64"));
    };
    
    Controller.prototype.ComponentSelectionPageCallback = function() {
      console.log("InstallDirPath: " + installer.value("InstallerDirPath"));
      console.log("ComponentSelectionPageCallback");
    };
    
    Controller.prototype.ReadyForInstallationPageCallback = function() {
      console.log("ReadyForInstallationPageCallback");
    };
    
    Controller.prototype.PerformInstallationPageCallback = function() {
      console.log("PerformInstallationPageCallback");
    };
    
    Controller.prototype.FinishedPageCallback = function() {
      console.log("FinishedPageCallback");
      console.log("version: " + Controller.componentVersion);
    
      var widget = gui.currentPageWidget();
      // デバッグコード
      // for (var key in widget) {
      //   console.log(key);
      // }
      if (installer.isInstaller()) {
        if (widget != null) {
          widget.title = installer.value("ProductName") + "のインストールが終了しました。";
          widget.MessageLabel.setText(installer.value("ProductName") + " " + Controller.componentVersion + ".\n" + "\"終了\"をクリックしてウィンドウを閉じてください。");
          //  <ー 『      のウィザードを終了するには"終了"をクリックしてください。』
        }
        // インストール終了時にウィンドウを残し、インストール終了をユーザに知らせる場合は下をコメントアウト
    //    // 強制的に「終了」ボタンを押す
        //    gui.clickButton(buttons.FinishButton);
    
        // 
        // デバッグコード
        var arr = gui.findChildren(widget, "*Button");
        console.log("length: " + arr.length);
        for (var k in arr) {
          console.log(arr[k]);
        }
      }  else if (installer.isUpdater()) {
        if (widget != null) {
          widget.title = installer.value("ProductName") + "のアップデートが終了しました。";
          widget.MessageLabel.setText(installer.value("ProductName") + " " + installer.value("Version") + ".\n" + "\"終了\"をクリックしてウィンドウを閉じてください。");
    
          if (Controller.keepDialogOnUpdate) {
    	QMessageBox.information("updator.finishing", "アップデート", "アップデートが終了しました。\nバージョン " + Controller.componentVersion, QMessageBox.OK);
    	gui.clickButton(buttons.FinishButton);
          } else {
    	if (installer.value("silent") != "true") {
    	  QMessageBox.information("updator.finishing", "アップデート", "アップデートが終了しました。\nバージョン " + Controller.componentVersion, QMessageBox.OK);
    	  gui.clickButton(buttons.FinishButton);
    	} else {
    	  gui.clickButton(buttons.FinishButton);
    	}
          }
        }
      }
    };
    
    Controller.prototype.LicenseAgreementPageCallback = function() {
    };
    
    Controller.prototype.RestartPageCallback = function() {
      console.log("RestartPageCallback");
    };
    
    Controller.prototype.installationFinished = function() {
      console.log("installationFinished");
      if (installer.isInstaller()) {
      } else if (installer.isUpdater()) {
        console.log("    isUpdater");
        if (installer.value("silent") != "true") {
          gui.clickButton(buttons.NextButton);
        }
      }
    };
    
    Controller.prototype.updateFinished = function() {
      console.log("updateFinished");
    };
    
    

Log in to reply