There are scenarios where you would need to find the sum or the average of all values in a QByteArray. This can specially happen if you are trying to send data using COM ports to devices that require the average or sum (or a similar combination) of all elements in order to check the integrity of data.
Continue reading “Quick Way to Find the Sum or Average of All Elements in QByteArray”How to convert QString to C String (char *)
The best solution for this would be to go through standard C++ and it means this:
Let’s say you have a QString, like this:
QString s = "www.amin-ahmadi.com";
First convert it to std::string and then use its c_str method, like this:
s.toStdString().c_str()
How to Find Min and Max in a Vector (Qt + STL)
In Qt, finding the minimum or maximum value in a QList or QVector can be frustrating sometimes and it also will complicate things when you just want a quick and simple minimum and maximum. Use the pieces of codes below to get them with a single line of code.
Continue reading “How to Find Min and Max in a Vector (Qt + STL)”