|
I suspect that what's going on is that when you highlight some text in your terminal window, its getting copied to a clipboard in the GUI. Or perhaps its not getting copied and you need to tell the terminal app to copy the text - usually, but not guaranteed to be, CTL-C. Otherwise, you might need to look into the GUI API for accessing contents of the clipboard. Note that many XTerm emulators seem to have 2 independent clipboards. There's one that you get when you merely highlight the text, and which you can then usually paste with middle-button on the mouse. There's also the Cut/Paste (CTL-C/CTL-V) clipboard. The two sometimes seem to be synchronized, but not always. In general, I think you should prefer the Cut/Paste method, as that seems to copy text to the GUI's idea of the clipboard, and is usually what you get back when you Paste. This is all a bit hand-wavy, because it seems like there's no hard and fast rules about what gets copied where during a highlight and/or a Copy/Paste.
Keep Calm and Carry On
|
|
|
|
|
I am currently looking into this hack
xterm has "log file " option and I am already redirecting the xterm output to
a temp text file. Unfortunately they both include control characters, but I already have a function to extract only the humanly readable text.
The hack would include adding another GUI level
I currently have a single subwindow , I would add
a new top layer "TAB" object and create
"raw " xterm output tab -same as today "native window"
extracted text tab - QT accessible
plus my usual TRACE tab
Little convoluted but that looks as the best solution so far
Then I can "copy and paste " from one subwindow (tab) to another
as my task initially called for.
|
|
|
|
|
When you highlight text in a terminal it can usually then be copied by some keystrokes or menu option. That is fairly standard throughout Windows, MacOS and Linux. You can then paste it into another running application (e.g. the QT process that launched the terminal), but as far as I am aware you still need to do it manually. If you want direct connection between a calling and called process, then the called process needs to be a console type application. You can then connect the stdout of the called process to stdin of the caller, so the caller can read what the called process writes. The QProcess documentation explains how to do it.
|
|
|
|
|
Thanks for the post. So far I am unable to copy from xterm , but I am working on that. As you said CTRL C is pretty standard and it should work. I will check the QProcess to see how to implement the console - in QT. There is something like that in xterm options, but I am not sure. That may lead to the solution.
|
|
|
|
|
I have no idea what you are trying to achieve, but is this even close:
Creating a Child Process with Redirected Input and Output - Win32 apps | Microsoft Learn[^]
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Yes, I am trying to communicate with external application - started by currently running application,
I did look at the link code and honestly at this point I am looking at the QT QProcess and do not want to start another code analysis.
However it looks as both QT and you code are using stdin/stdout which seems to be a solution to my issue.
Many thanks for your post, appreciate any help.
|
|
|
|
|
More I get into this the more confused I am .
The Qt QProcess starts external application...
Per Qt QProcess doc
Processes have two predefined output channels: The standard output channel (stdout) supplies regular console output, and the standard error channel (stderr) usually supplies the errors that are printed by the process. These channels represent two separate streams of data. You can toggle between them by calling setReadChannel(). QProcess emits readyRead() when data is available on the current read channel. It also emits readyReadStandardOutput() when new standard output data is available, and when new standard error data is available, readyReadStandardError() is emitted. Instead of calling read(), readLine(), or getChar(), you can explicitly read all data from either of the two channels by calling readAllStandardOutput() or readAllStandardError().
I am decoding the above as QProcess can communicate with the started external application using standard stdio/stdout.
Now the application started is "xterm" which executes "bluetoothctl".
I am redirecting the result of the "bluetoothctl" output to temporary file...
I have "xterm" itself optioned for logging and have the log file - it has SAME contents and format as
my temporary "bluetoothctl" file .
I have added "connect " to my code to capture any of this "printing" , but the SIGNAL ( as described in the doc snippet ) never arrives - hence neither xterm logging process nor bluetoothctl temp file are stdin/stdout.
My question - what processes / prints the xterm log and the bluetoothctl file?
Obviously these (prints) are not standard stdin/stdout.
I realize this is no longer C code issue, actually it never was pure C code issue ,
but still getting no help from QT forum.
PS xterm has "-C" - console option , but using it did not resolve the issue.
|
|
|
|
|
Do you need to wrap bluetoothctl in an xterm for some reason, can you not just call QProcess with bluetoothctl as the program to execute?
Keep Calm and Carry On
|
|
|
|
|
I have changed the QProcess - now it starts bluetoothctl directly and it generates
what appears to be stdout SIGNAL to run readFromStdout() function.
That is very encouraging, however, I have no idea how to actually read whatever initialized this SIGNAL.
When I run debug I get ton of data , but have no clue what I am looking for.
The attached code attempt to read it is not working.
I am assuming the "stdout" is in some kind of buffer...
And to read it - should I be using "stdin"?
<pre>int CCC_MdiChild::readFromStdout()
{
#ifdef TRACE_MDI_XTERM
qDebug()<< "TRACE_MDI_XTERM " <<Q_FUNC_INFO;
qDebug()<< "TRACE_MDI_XTERM @line " << QString::number(__LINE__);
#endif
QString TEST = QTextEdit::toPlainText();
qDebug() << "TEST " << TEST;
QTextStream out(stdout);
qDebug()<< "read all " << out.readAll();
out << QString("Some text");
QTextStream in(stdin);
qDebug()<< "read all " << in.readAll();
out << QString("Some text");
|
|
|
|
|
|
I need to fully digest how it all connect. I follow your suggestion and others so do not get so huffy.
Actually to most important suggestion was to run "bluetoothctl" direct.
As far as I can tell now - the QProcess executed the "xterm" with option to execute bluetoothctl.
However - I was not getting SIGNAL.
BUT if set the QProcess to run "bluetoothctl" , thus bypassing the "xterm" I do get the expected SIGNAL.
So the full "pipe" from "xterm" to "bluetoothctl" is not there... the required SIGNAL is missing, the question remains - WHY?
|
|
|
|
|
Member 14968771 wrote: do not get so huffy. There's only one person here who gets huffy.
The main problem with your question is that it is far from clear exactly what you are trying to do, or why you are using QT. If you merely want to capture the output of some command, then running it in xterm is not a good choice. But since the reason for xterm was not clear I did not originally question it. However, I did point out that connecting processes via stdin, stdout is something that has been around since the early days of Linux/Windows, and is actually fully supported by QProcess.
|
|
|
|
|
The main problem with your reply - to paraphrase it - is you are avoiding to provide a solution. It is not a question what I am trying to do and why I am using Qt.
It has been established that QProcess can detect change in stdout
, you have pointed that out yourself and it helped immensely , - what IS not RESOLVED is WHY the combination of "xterm" executing "bluetoothctl" does NOT set stdout, when each command used individually sets the stdout data.
If you cannot contribute to the solution to this , remaining issue, do not waste your time asking why I am using Qt.
|
|
|
|
|
Member 14968771 wrote: you are avoiding to provide a solution. Yes, mainly because I still do not really understand what you are trying to achieve. But, hey ho, that seems to be par for the course with your questions.
|
|
|
|
|
Write a program that calculates the following expression: total = (num3 + num4) - (num1 + num2) + 1
|
|
|
|
|
OK, I've done that. Where do I submit my invoice for payment?
Seriously, nobody here is going to do your homework for you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Greetings Kind Regards Each of the two uses of the type trait is_base_of compiles differently. One w/ error the other w/o. Any idea why the difference? It is documented as requiring a completed type I am not certain as to its meaning but the question remains why the difference? Thank You Kindly
The precise error message wrt the requires expression is:
1>D:\a\_work\1\s\binaries\x86ret\inc\type_traits(1152,28): error C2139: 'cDERIVED': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_base_of'
hello_world.cpp(5): message : see declaration of 'cDERIVED'
hello_world.cpp(7): message : see reference to variable template 'const bool is_base_of_v<cbase,cderived>' being compiled
hello_world.cpp(9,2): error C7602: 'cDERIVED::someClass': the associated constraints are not satisfied
hello_world.cpp(8): message : see declaration of 'cDERIVED::someClass'
hello_world.cpp(7,32): message : the constraint was not satisfied
hello_world.cpp(9,22): error C2955: 'cDERIVED::someClass': use of class template requires template argument list
hello_world.cpp(8): message : see declaration of 'cDERIVED::someClass'
1>Done building project "hello_world.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:02.511 ==========
import std.core;
using namespace std;
class cBASE {};
struct cDERIVED : public cBASE
{
template<typename T> requires is_base_of_v<cBASE, cDERIVED> class someClass {};
someClass<cDERIVED> someData;
constexpr bool TEST_is_base_of() { return is_base_of_v<cBASE, cDERIVED>; } };
int main()
{
cout << "Hello World\n";
cout << boolalpha;
cDERIVED _derived;
cout << _derived.TEST_is_base_of();
}
modified 28-Sep-22 14:14pm.
|
|
|
|
|
Could you post the exact error that you are seeing?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Thank You for your interest. Please see updated post. Kind Regards
|
|
|
|
|
I am saving a series of floating point numbers in CSV. I heard that under some European locale, the decimal point in floating point is actually a comma, I was wondering if I release this product in a European market, will my library have trouble parsing the floats since my decimal point is a full stop, not a comma.
Does anyone encounter this problem in those locales? How do you handle it?
Thanks in advance.
|
|
|
|
|
Any decent CSV library should take care of this by quoting anything containing the field delimiter (in this case, comma).
I just did a simple test with LibreOffice Calc:
* entered 123.45 and 246.80 in the first two cells.
* changed its locale to German
* saved as csv
The result: "123,45","246,80"
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Thank you for your reply. How about parsing float numbers with full stops in German locale? I am not sure if the C++ stof() handles it since the C++ Reference page states it is determined by the current C locale.
std::stof, std::stod, std::stold - cppreference.com
|
|
|
|
|
I haven't done anything serious in that area for at least a decade, but from memory you need to set the locale programmatically to be sure of where you are when you parse input.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
There is any we understand or convert or any other way we use .hex file and creat any plc language or program in plc language
|
|
|
|
|
And what is your question?
|
|
|
|