Summary: Usually, we run the shell program is in the terminal, and in the product, it is not possible to call the user to the terminal to hit the command bar; Also, when a system in a certain calculation function, I have done in another program, want to use the GUI program directly invoke it to run. So, in these cases, how do you run the shell script and the Linux program with the button on the GUI? The following is an example of how to invoke a shell program and run an application in a QT4 GUI program on mini6410.
With this example, you can test the functions of the Linux C library to invoke shell scripts and applications, or you can call the shell scripts and applications through QT functions. Blocking and non-blocking runs are also described.
Introduction: Introduction: Based on mini6410 development platform, using QT4 to design a GUI interface HelloQt4, through the HelloQt4 interface button->clicked to start the SMPlayer player.
1, Design GUI graphical interface, create a button, and add code under clicked
The first method (50 lines) is to invoke the system (const char *string) in the Linux C function library;
The second method (51 lines) and the third method (53 54 lines) are functions in the QT;
When you need to explain, the above three methods are OK, but the first two methods block the process until the SMPlayer program ends, and the third method does not block the process and can run multiple tasks.
Also, we know that QT when running, to start Qws (qtwindows server), if the previous two methods, then SMPlayer run, to open a new qws, otherwise can not run, and in the third Way, you do not need to open the QWS, It shared a qws with HELLOQT4, so that the two programs could be seen in a single window.
2. New run script to start SMPlayer player
In the previous step, the QT program executed the/opt/run_smplayer script, but this script does not exist, we want to create it, open the/OPT directory of the Development Board, create a new Run_smplayer file, add the following
3. Modify SMPlayer File
In a friendly root file system, the SMPlayer script in the/user/lical/smplayer/bin directory is problematic, and if you run it directly, there will be situations where the mouse and touchscreen are not available, and we will copy the SMPlayer script from the/bin directory. and remove the QWS from the last two lines. (As mentioned above, we want to multitask, we don't need to open another qws)
Export Home =/Root
Cd/usr/local/smplayer/
Exe__c. /SMPlayer #-QWS 1 >/dev/null
2 >/dev/null//Here is the screen word, true without underline
#hotplug
4, modify the RCS file, so that the boot on the run helloqt4i program
The RCS file is as follows:
# !
/bin/sh
PATH =/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:
RunLevel = S
Prevlevel = N
Umask 022
Export PATH runlevel Prevlevel
#
# Trap Ctrl-c & C in
This shell so we can interrupt subprocesses.
#
Trap ":" INT QUIT TSTP
/Bin/hostname Crt
If [-c/dev/touchscreen]; Then
Export Qws_mouse_proto = "Tslib:${tslib_tsdevice} mouseman:/dev/input/mice"
If [-e/etc/pointercal-a!
-s/etc/pointercal]; Then
Rm/etc/pointercal
Fi
Else
Export Qws_mouse_proto = "Mouseman:/dev/input/mice"
>/etc/pointercal
Fi
Then, restart the Development Board, HELLO_QT4 program run, and then click the button, the player also bounced out.
Conclusion: This routine is simple and practical, and describes the purpose of the function,
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.