Use of QT process programming: Calling another program in one program

Source: Internet
Author: User

In QT programming, it is sometimes necessary to call an already written program to process the data in the program being written.

The process needs to be used to invoke the already written program.

Write the good one layout program beforehand:

#include <QApplication> #include <QPushButton> #include <QGridLayout> #include <qlabel># Include<qlineedit> #include <qmainwindow>int main (int argc, char *argv[]) {qapplication app (argc, argv); Qwidget *window = new Qwidget;  Qgridlayout *vlayout = new qgridlayout (window); Qlabel *label1 = new Qlabel ("Query", window); Vlayout->addwidget (label1,0,0); Qlineedit *edit1 = new qlineedit (window); Vlayout->addwidget (edit1,0,1); Qpushbutton *button1 = new Qpushbutton ("Query", window); Vlayout->addwidget (button1,0,2); Qlabel *label2 = new Qlabel ("Answer", window); Vlayout->addwidget (label2,1,0); Qlineedit *edit2 = new qlineedit (window); Vlayout->addwidget (edit2,1,1); Qpushbutton *button2 = new Qpushbutton ("Clear", window); Vlayout->addwidget (button2,1,2); Window->setlayout (vlayout); Window->show (); return app.exec ();}



Put it under the Layout folder

Qmake-project

Qmake

Make

Get the layout executable file


You can invoke the Lauot program by adding the following code when you write another program:

QString program = ". /layout/layout ";//Specifies the path of the executable program to invoke qprocess *myprocess = new Qprocess (this); This means that Myprocess's parent window is the main window in this program, and when the main window is closed, the process terminates,//If the this,myprocess is independent, the main window is closed and the process is still running Myprocess->start ( program);



If the program has parameters, it is written in the following form:

QString program = ". /layout/layout "; Qstringlist arguments; Arguments << "*" << "*"; Add parameter qprocess *myprocess = new Qprocess (this); Myprocess->start (program, arguments);

Reference: QT Help documentation





Use of QT process programming: Calling another program in one program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.