Unsolved Pop up a progress bar on a pushed button (QML)
-
Hey guys,
I have a problem with a progress bar in QML. Here is my QML file.
import QtQuick.Controls 1.4 Rectangle { id:root width: 500 height: 550 Launcher { id: launcher } Button { x: 125 y: 400 width: 262 height: 45 text: "Start" onClicked: { popup.open(); launcher.open_terminal(); } anchors.horizontalCenter: parent.horizontalCenter } Button { x: 125 y: 450 width: 262 height: 45 text: "Close" onClicked: { Qt.quit() } //highlighted: true anchors.horizontalCenter: parent.horizontalCenter } Image { anchors.horizontalCenter: parent.horizontalCenter source: "index.png" } Popup { id: popup ProgressBar { id: pb1 minimumValue: 0 maximumValue: 100 value: 0 } // Timer to show off the progress bar Timer { id: simpletimer interval: 100 repeat: true running: true onTriggered: pb1.minimumValue < pb1.maximumValue ? pb1.value += 1.0 : pb1.value = pb1.value } } }
Is very simple., "launcher.open_terminal();" run an external C++ executable. The problem is when i push the button the external executable start and after he is done the job the progress bar start. I wold like first to start the progress bar and after that the executable. Has anyone any idea how can i do this? So maybe a better idea then "popup". (i couldn't find other better solution)
Thank you. :) -
Can you show the body of Launcher::open_terminal()?
-
Sore, here it is
void TerminalLauncher::open_terminal() { this->proc.start("C:\\Windows\\System32\\calc.exe", QIODevice::ReadWrite); this->proc.waitForFinished(-1); }
-
@Alex11 said in Pop up a progress bar on a pushed button (QML):
this->proc.waitForFinished(-1);
No wonder it does not work as you're waiting for the process to finish!
Why do you wait? Just remove that line. -
I can not do that because here calc.exe is just an example. In place of calc.exe i have my own executable and i need to wait until he finish because he write data in a xml file, and when he finish writing i lunch a new qml page with data from xml.
So i need to find a way that my external process to run until he finish and in the some time to start also the progress bar. Maybe with a new thread or something like this but i cannot find a way yet. -
Do not use the Sync API, connect a slot to the QProcess::finished signal to know when the process is done writing the xml and remove the waitForFinished
-
ok, i will try to give a shut. I will came back with a result. Until now i can not fix it yet.