I'm trying to send a keyboard input from a C++ application (I'm using Qt5 framework). I successfully run ydotool as external QProcess but I'm searching for a better and more "c++" way of doing this, without using external modules (ydotool needs a runtime run as root and each command must be run as root too, it needs some work to make it work correctly, I'd like something simpler from the user side).
Any idea?
thanks in advance!
Related
I'm currently working on a console application with Qt, and I was wondering, if there is any way to automatically test my application, so I don't have to test everything manually. I've searched the web, but haven't found anything yet.
If there is no way to do this with a preexisting framework, would it be possible to have an extra thread writing to, and reading from stdin and checking on this thread if the program is behaving correctly? If yes, how exactly would I do this? (I'm a beginner at everything multithreading)
Thanks in advance.
I'm not sure if anyone asked this, I tried to find it but I couldn't. I'm starting a new project and I want to make a GUI in C++ that will run another application called "GAMS" which does some optimization problems for me.
Now, I do know how to create GUI and how to run GAMS itself using ShellExecute(), but I don't know how to run those algorithms from my GUI.
All I need is to run scrip that I wrote in GAMS and that I would be able to manipulate with data that I receive from GAMS.
So my question is, can I send commands from my GUI to GAMS?
Thanks in advance!!
I'd like to run commands and show the output in quite a few Ubuntu Touch apps I'd like to create, so therefore I need to create a plugin for QML in C/C++(?) with this functionality.
The thing is that I don't know anything about C/C++, nor do I really want to learn it. However I do need it now and I need help to get going.
How would I create this plugin? Where do I start?
Thanks in advance,
Daniel
You can always wrap QProcess which allows you to run any shell command.
Check this out
And for Ubuntu touch you can use wizard for qml plugins. Its quite easy actually.
I got help from Joseph Mills: https://code.launchpad.net/~josephjamesmills/+junk/launchTotem
You shall use PlasmaCore.DataSource with the engine "executable", as in this example.
Mind that the call is asynchronous. Hence the command sends a signal when it finishes, and a different part of the code picks the signal and continues with the next step you want to perform.
I am a beginner is C++. I am trying to find, is it possible to run my program in both in QT window and Linux based. When the user logins into my system, the user can select GUI or terminal mode to run the system.
Thus, I would like to know is it possible to do it. If possible how can I proceed on? What command should I use to switch from a QT window to a terminal?
Do I need to create a separate set of project for both individually or using the same set of classes?
All Linux programs (unless explicitly disabled) print out text to a terminal. If you run the program in a graphical environment you will probably not run it from a console, therefore you won't see the output, but it will be still there.
If you want your program to be usable from a console, just test whether you could create the main window and if not, fallback to simple text output.
Note that the binary will still require the X server and Qt libraries to be installed.
You can construct your application with or without the GUI enabled through the QApplication constructor. Consult the example in Qt's documentation:
http://qt-project.org/doc/qt-4.8/qapplication.html#QApplication-2
Though, it should be noted that everything in Let_Me_Be's response is correct. In fact, the Qt example does exactly what he's suggesting. Please take the time to understand his answer before you plunge into coding.
Is there any way of writing pexpect like small program which can launch a process and pass the password to that process?
I don't want to install and use pexpect python library but want to know the logic behind it so that using linux system apis I can build something similar.
You could just use "expect". It is very light weight and is made to do what youre describing.
For very simple cases, empty is one option. It's a lightweight C program, and it can be used straight from a shell script and doesn't require Tcl.
For Debian/Ubuntu, the package is empty-expect.