Last active
November 25, 2020 04:41
-
-
Save bob-ross27/6e4d54c4dba74e67a42b6d88af8083bc to your computer and use it in GitHub Desktop.
Example QTProgressBar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example QTProgressBar. | |
*/ | |
function progressbar() { | |
/** | |
* Sleep for a duration. | |
* @param {*} sleepDuration | |
*/ | |
this.sleepFor = function (sleepDuration) { | |
var now = new Date().getTime(); | |
while (new Date().getTime() < now + sleepDuration) {} | |
}; | |
/** | |
* Create the QT ui. | |
* @returns {QWidget} ui object. | |
*/ | |
this.createui = function () { | |
this.ui = new QWidget(); | |
this.ui.layout = new QHBoxLayout(); | |
this.ui.progressbar = new QProgressBar(); | |
this.ui.progressbar.setMaximum(100); | |
this.ui.layout.addWidget(this.ui.progressbar, 0, 0); | |
this.ui.setLayout(this.ui.layout); | |
return this.ui; | |
}; | |
this.ui = this.createui(); | |
this.ui.show(); | |
for (var t = 0; t < 100; t += 1) { | |
this.ui.progressbar.value = t + 1; | |
this.sleepFor(50); | |
} | |
MessageBox.information("Operation complete."); | |
this.ui.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment