hi,
I am writing a Qt application, where i have a "helloworld.py" and "helloworld .ui" file.
but i m getting trouble here, i wanna run /execute this .py file from within the qt application.
i have searched a lot on internet, and came across the QProcess class.
i tried to use it.(used start and execute methods from the class), but i dint get the results,
can anyone pls ans my question.
my code is bellow
QString scriptFile
= "D://QTDev//QuickEditor//helloworld.py";
process.execute("Python D://QTDev//QuickEditor//helloworld.py");
process.start("cd D://QTDev//QuickEditor//");
process.start("Python D://QTDev//QuickEditor//helloworld.py");
process.waitForFinished(1000);
QProcess process;
QString scriptFile = "D://QTDev//QuickEditor//helloworld.py";
process.execute("Python D://QTDev//QuickEditor//helloworld.py");
process.start("cd D://QTDev//QuickEditor//");
process.start("Python D://QTDev//QuickEditor//helloworld.py");
process.waitForFinished(1000);
To copy to clipboard, switch view to plain text mode
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
def __init__(self):
self.setupUi(self)
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.verticalLayout.setObjectName("verticalLayout")
self.pushButton.setObjectName("pushButton")
self.verticalLayout.addWidget(self.pushButton)
self.
label = QtWidgets.
QLabel(Form
) self.label.setText("")
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
self.retranslateUi(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", "Press Me!!!"))
self.pushButton.clicked.connect(self.printHello)
def printHello(self):
print( "Hello World !")
if __name__ == '__main__':
ex = Ui_Form();
ex.show();
sys.exit(app.exec_())
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
class Ui_Form(QtWidgets.QWidget):
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setupUi(self)
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setObjectName("pushButton")
self.verticalLayout.addWidget(self.pushButton)
self.label = QtWidgets.QLabel(Form)
self.label.setText("")
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", "Press Me!!!"))
self.pushButton.clicked.connect(self.printHello)
def printHello(self):
print( "Hello World !")
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv);
ex = Ui_Form();
ex.show();
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks