Qt Network chat Example - qt

I am running network-chat example in QtCreator, I just run one Instance of program and without closing it running another one, but they are not chatting, nor each dialog showing Presence of another. Pls tell me what is the problems.

Related

Start a background process on Qt and load responsive shell environment

I am playing around with Qt to create a simple GUI for some more advanced analysis with the software called OpenFOAM. Right now, I want to start an application of the toolbox OpenFOAM usingQProcess::execute. It is working but for the application I need to load the environment in the shell.
Commonly, if I work in the terminal I first do have to source the environment file that loads all libraries and solvers one can use. However, in Qt, I am not aware how to achieve that.
Example. In the terminal I need to do the following:
source /path/to/environementFile
simpleFoam > logFile << application
I want to start the application simpleFoam in the background of my GUI after clicking on a button. Right now, I do have the following:
QProcess::execute(QString("/home/shorty/OpenFOAM/platforms/bin/simpleFoam"));
This works but the shared library that are needed by the application are not loaded (missing source of the environment file). Is there a way how to process more commands within one execution call?

QTCreator Memcheck performing analysis without letting me run the actual program?

I am attempting to use QTCreator's Memcheck tool to analyze the memory of a QT project, which is a dynamic library. It uses a QT Gui (QMainWindow) to allow the user to select a file, which is then processed, and then eventually returns to the mainwindow.
However, I cannot seem to use Memcheck properly.
When I select "Memcheck" and hit run, it instantly goes to "Analyzing memory" without ever letting the Gui pop up.
This is problematic. How can I get memcheck to work with this program?
I had two main issues:
1: Valgrind does not seem to play nice with QT Gui applications. It generates logs that are thousands of entries long for all the work QT is doing before it even gets to my application.
I had to make a separate, small non-GUI C++ program that would drive instead of the GUI application.
2: When trying to run from the command line, I needed to set an environment variable by using export. This needs to be the same as LD_LIBRARY_PATHS in QT Creator.
So I ran:
export LD_LIBRARY_PATH=X where X was the exact value I copied from LD_LIBRARY_PATHS in the variable from the QT Project.
Note: Running from the command line may have not be neccesary now that it isn't a GUI Application, memcheck might have passed just fine. Haven't tested since.

Mouse not clicking the intended image using sikuli library for robot framework on virtual machine (azure)

i am currently running robot tests using sikuli library(for a desktop application) on a virtual machine in azure.
I have problems with mouse not clicking intended image. and i get the error below.
[error] RobotDesktop: checkMousePosition: should be L(209,150)#S(0)[0,0 2049x1152]
but after move is `L(210,150)#S(0)[0,0 2049x1152]`
Possible cause in case you did not touch the mouse while script was running:
Mouse actions are blocked generally or by the frontmost application.
You might try to run the SikuliX stuff as admin.
[log] CLICK on L(209,150)#S(0)[0,0 2049x1152] (562 msec)
Could someone help me how to solve this issue. i tried running the script as an admin and also checked resolution but still doesnt work.
Any help would be appreciated. thanks.
That message is thrown usually because lack of privileges. If you tried running the program vía command line, try to create a new user with Administrative privileges. Later, execute the program with Shift + Left Click --> Run as ... and enter the new credentials. That should work.

Launching of process on mac using Qt

i am working on sample applications using QT on Mac and i found out problem with one of its API. I want to run process so i am using following function
QProcess::startDetached();
And i am passing program(location of exe )and argument list as parameter now problem is that if the application is allready running then the this will create another process and runs it where as when i cross cheked with Windows its behavior is different in the sense that it does not start application which is allready running. can anyone help me how to fix the issue??
I think, it depends on the application properties. On window you can open multiple Doc files but cannot open Window Media player in two different (new) window.
So, First try opening a new application while its running. If its success, then it should work with QProcess .

How to call an app that expects stdin input from QtGui?

I'm using Ubuntu and Qt Creator 4
I have a .cpp program in the executable form (say abc.out) that I wish to run when I press a button. It contains a number of cin and cout, so I want it to run on a "terminal" (on Ubuntu) so that I am able to input and output values to it. How can I do that?
I've tried system() and
also,
QProcess p1;
p1.start(./abc.out);
Using QProcess, my executable runs but stops at the first cout. It runs on the application output screen in Qt Creator and not on terminal.
For example:
I see on application output:
enter name:
When I type the value and press enter here, it doesn't accept the value, but moves to the next line and allows me to type further.
I want to run this abc.out file on the terminal. Any ideas would be really helpful.
Do you mean Qt Creator 2.4? In any case, on the Projects tab, you should find the Run settings section and from there you can find a "Run in terminal" checkbox. You could also use a Custom Executable option and type there: gnome-terminal --command ./abc.out The exact details can vary a bit as I'm using Qt Creator 2.5.
This should work when launching from Qt Creator, but when you use your app outside the IDE, you need to launch it from terminal and not by double clicking the executable. To fix this, I can think of two ways:
Launch a terminal window from QtGui (something like QProcess::execute("gnome-terminal --command ./abc.out"); ), though the problem is different systems have different terminal names.
Provide a Qt input/text box yourself as part of your GUI which then forwards the user input to the executable (something like myqprocess.write(input_asked_from_user_by_QtGui); ). Here you probably need to know what information to ask the user beforehand. If you want to display the cout output of the started process, you can use the read method and friends of the QProcess.
From your question I assume that you are writing an application that launches other applications using QProcess. Thats fine, but if your subprocess is waiting for data from the standard input it will wait forever since you did not provide any data. The stdin of your parent application cannot be automatically guided to the subprocess. Imagine you are starting two processes from your main app. To which child process should the input go?
If you want to communicate with child processes, you must use the QIODevice methods of QProcess and send/read data from/to that application.
The only sensible solution is to launch the target application in a terminal. Whether your own code provides the terminal window or you reuse an existing terminal application is up to you.

Resources