|
C++ doesn't have get and set , although you can provide functions with those names. Are you sure this isn't supposed to be C#?
But in the greater scheme of things, it sounds like you're asking for someone to do your assignment, which is something that rarely happens on this site, and certainly not for something of this size.
|
|
|
|
|
Coding?
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
QStringList params = QStringList() << "qterminal" << "-e" << "bluetoothctl help"
The rude tone of your question would not have deserved an answer but maybe you'll learn to be polite.
Mircea
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
We are getting your rants, and you are not getting what you want, because you keep asking the same questions and people don't keep track of someone who goes by just a "number".
The bottom line is: This is NOT a "bluetooth" (expert) site, and all your ranting won't change that. If there is one here (an expert), he may not care to contribute under the circumstances; and that's their choice.
You may not realize it, put people do not knowingly volunteer a "wrong" answer. If you don't like the answer, or have heard it before, keep it to yourself. You create a thread; expect different answers; deal with it (and this post).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Member 14968771 wrote: The att6ached code is being posted here because
it is C++ code No, it has nothing to do with C++, it is purely a QT/qterminal issue. And this is the C/C++ forum.
In your code ...
QString exec = "qterminal";
QStringList params = QStringList() << "qterminal" << "-e" << "bluetoothctl" ; processTERMINAL->start(exec, params);
... you are passing "qterminal" as the first parameter to "qterminal" . So remove that field from your params .
And that is still not a C++ issue.
modified 5-Sep-22 4:30am.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Did you try to compare your these two "usages" to see the difference between them?
|
|
|
|
|
|
Quote: 1. I thought 'foreach" was a C++ "feature" - in QT doc they call it macro "Q_FOREACH" -
not sure which way is up... Then you were wrong. C++ has NO foreach construct, however, it provides the range-based for , see Range-based for loop (since C++11) - cppreference.com[^].
Quote: 2. The syntax
foreach(QString str, StringArray[MAX_ARRAY]) I cannot find the StringArray class in QT documentation. Do you meant QStringList Class | Qt Core 6.3.2[^]?
On the other hand, if you use a (C -like) array of QString s, then you could use the C++ range-based for .
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
You are welcome.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
QString offers a standard C++ iterator: QString Class | Qt Core 6.3.2[^]. So (assuming qstr is the reference to your string) you can try something like:
for (QString::iterator it = qstr->begin(); it != qstr->end(); ++it)
{
}
|
|
|
|
|
I am dealing with a school exercise in c++ within an Ubuntu virtual machine. I have a header.h with the class, a header.cpp with the method implementation, a main.cpp and i compile it (main.cpp includes header.cpp which includes header.h) with the following: g++ main.cpp -Wall -o main (from ubuntu terminal). Then I run it and that's ok.
I then tried to import the same exercise in visual studio 2019 creating at first an empty c++ project. After I tried with a CMake project. In both cases compiler/linker return error LNK2005 relevant to all the method implementation saying that they are already defined in main.cpp.obj.
I would attach the complete project in both versions (Ubuntu side and vstudio19 side) but I do not see how. Regards
|
|
|
|
|
Roberto64_Ge wrote: main.cpp includes header.cpp which includes header.h
This is probably the source of your problem. Visual Studio is probably compiling header.cpp and creating a separate object file, then compiles main.cpp, which includes header.cpp, and so creates two copies of the methods defined in header.cpp. In general it is a mistake to #include a cpp file in another cpp file. You main.cpp only needs to include header.h, which should only provide a declaration of your class. You would then compile main.cpp and header.cpp separately.
You can do this on the ubuntu command line using
g++ -Wall -Wextra main.cpp header.cpp -o main or alternatively
g++ -Wall -Wextra -c main.cpp
g++ -Wall -Wextra -c header.cpp
g++ main.o header.o -o main In the above example, the -c option to g++ tells the compiler to only produce an intermediate object file (e.g. a .o file), and not try to produce an executable. The third line creates the final executable, and includes all the system libraries and startup code needed for the executable.
Keep Calm and Carry On
|
|
|
|
|
Thank you, your answer is clear. Now the point is that I am not used at all in c++ compiling/linking and I am not used to VS configuration of compiler and linker, so I ask if you could help. Correct me if I am wrong : (we are within VS2019)
1) a create a new cc++ emty project
2) Add main.cpp , header.cpp and header.h to the project.
3) Include header.h in main.cpp
Now from the VS2019 environment, how do I compile separately main.cpp and header.cpp? I guess I have to compile header.cpp before. Isn't it? But how do I do that?
And then, how do I compile main.cpp and how the VS2019 knows, while compiling main.cpp, where to get the method implementation i.e. the header.obj?
|
|
|
|
|
If you've created a VS C++ project, it knows how to deal with files that you add to the project. All you should need to do for a simple project is hit Build, and the IDE will take care of the rest.
Keep Calm and Carry On
|
|
|
|
|
Ok I tried and I did it. I right clicked on header.cpp and it gave the option to compile. This created the header.obj. Then I right clicked on the main.cpp and again I had the option to compile it and this generated the exe. Before doing all this I included in the main.cpp only header.h,
Now it works. Thanks for the clear explanation
|
|
|
|
|
|
|
Roberto64_Ge wrote: main.cpp includes header.cpp which includes header.h This means that all the definitions in header.cpp will be duplicated in the object files. Do not include .cpp files in others, only include the actual headers, i.e. in this case main.cpp should only include header.h.
|
|
|
|
|
|
I there a way to track down the linker errors further than what`s being offered in the "Build output" window?
|
|
|
|
|
Not really. You can increase number of linker messages by changing the "Show Progress" option. The "Display all messages" is really verbose.
Otherwise, sometimes they can be tricky to trace. Just yesterday I had one where an include directive was used after a
namespace blah_blah { line. Linker was looking for a function definition inside the namespace when it was actually outside.
Mircea
|
|
|
|