Comment by Ali Tavakol on Pass value from annotated method to @Around aspect
@tsamridh86 value here is not constant. edited.
View ArticleComment by Ali Tavakol on Why is iterating over the set and modifying element...
@super how does compiler know this? and throws error?
View ArticleComment by Ali Tavakol on Why is iterating over the set and modifying element...
about the empty set: I removed non-related code.
View ArticleAnswer by Ali Tavakol for Use QTimer outside QObject
Does this help?QTimer::singleShot(2000, [=]() { foo(); });
View ArticleAnswer by Ali Tavakol for Suppose I have a completely functioning program and...
Does this help?PROG:class C { void f();}#ifndef TESTvoid C::f() { // implementation}#endif // TESTTEST:#define TEST#include "main.cpp"// Your test code here can have instances to class CC c;c.f();But...
View ArticleAnswer by Ali Tavakol for removing a zero width character in c++?
Instead of sLabel.erase(remove(sLabel.begin(), sLabel.end(), ''),sLabel.end()); please try this:std::string from = "", to = "";size_t start_pos = 0;while ((start_pos = sLabel.find(from, start_pos)) !=...
View ArticleWhich one is the acceptable convention for undo / redo behavior?
Suppose this is a mathematical application that manipulates waveforms. User opens a waveform file, and edits it.Now user amplifies waveform using the application toolbox. Amplification may take a long...
View ArticleLink a C++/CLI DLL to a Qt C++ application
There is a dynamic library mylib.dll written in C++ and compiled with Visual Studio, with common language runtime (/clr) support, that exports a function:bool __declspec(dllexport) exported_func();And...
View ArticleAnswer by Ali Tavakol for Dummy value output by Pointer
There is a problem with int pixels[MAX_SIZE]; inside the readImage function. It is allocated on the stack, and will be released when call returns. You have to allocate on heap using the new operator.
View ArticleAnswer by Ali Tavakol for C++ linked list not displaying String type variables
With malloc, class constructor doesn't get called. Use new instead.
View ArticleAnswer by Ali Tavakol for Why the program crased even thoungh I got the...
Problem is InitList initializes a local copy of L, but not the L that is in your main function. Change it to InitList(LinkList **L) and call as InitList(&L);, and change your implementation...
View ArticleAnswer by Ali Tavakol for C custom datatypes mapped to C datatypes grouped...
You may assign a unique ID number to each data type, and have both sides of the message passing line agree on it. Apparently you cannot compare data types, i.e. if (data_type == MPI_INT), but you can...
View ArticleAnswer by Ali Tavakol for compiling a .pro file using qt-creator with...
It's good practice to avoid adding local machine-specific paths to source files of a community project. For Qt projects, add them in the additional arguments section of qmake settings in project build...
View ArticleAnswer by Ali Tavakol for How do I extract an integer in a string?
Search using the regular expressions: #include <regex>#include <iostream>int main(){ const std::string s = "\"1001\", John Martin"; std::regex rgx("\"(\\d+)\", *([\\w ]+)"); // this will...
View ArticleAnswer by Ali Tavakol for how to use map value by key when the value is an...
Because key you pass to GlobalVars.at("A") is address to a location that differs from what you passed during map initialization. In fact problem is not about pointer value. For example, for const char...
View ArticleAnswer by Ali Tavakol for boost::filesystem::space() is reporting wrong...
Use a type that boost::filesystem::space(p).free requires. it may require a 64 bit integer type:uintmax_t freeSpace = boost::filesystem::space(p).free;use of auto is also good.
View ArticleAnswer by Ali Tavakol for What happens in background or in memory when we...
This is the result of ((51×256+50)×256+49)×256+48, where 51 is ASCII code of '3' and 50 is ASCII code of '2' and so on. In fact, pp[0] points to 4 bytes of memory (int is 4 bytes), and those 4 bytes...
View ArticleAnswer by Ali Tavakol for Finding the maximum tuple in a vector
I add my flavor to what @2power10 answered:auto result = std::max_element(v.begin(), v.end(), [](const auto &x, const auto &y) { return std::get<2>(x) > std::get<2>(y); });
View ArticleAnswer by Ali Tavakol for Determine Next Point on a Line Between Point A and...
With A = (x1,y1) and B = (x2,y2) the line is (expressed in two same equations):(1) y = (x-x1)*(y2-y1)/(x2-x1) + y1(2) x = (y-y1)*(x2-x1)/(y2-y1) + x1To find next point, put x1+1 (or x1-1 you know) in...
View ArticleLoad huge text buffer into QPlainTextEdit
What is the correct and optimum way to show a huge text buffer in a QPlainTextEdit widget? I mean listen to scrollbar move events, and dynamically pass only the visible portion of the text to the...
View ArticleQt window layout spans beyond window borders when QOpenGLWidget is present
There is a Qt window, which hosts many widgets, among them is one QOpenGLWidget widget to plot waveform. This works well on almost all machines, but there is one strange case with a machine having an...
View ArticleAnswer by Ali Tavakol for C++: Read in complex numbers from a .txt file and...
I recommend using regular expressions. This is my method:#include <iostream>#include <fstream>#include <string>#include <regex>int main() { std::regex...
View ArticleAnswer by Ali Tavakol for How to link a template library in Visual Studio 2019
After extracting the Eigen, add path to its root directory (which contains another Eigen directory just inside) to the list of additional include directories of the quadcopter-simulation project. (open...
View Articlestd::atomic to what extent?
In the C++ Seasoning video by Sean Parent https://youtu.be/W2tWOdzgXHA at 33:41 when starting to talk about “no raw synchronization primitives”, he brings an example to show that with raw...
View ArticleAnswer by Ali Tavakol for reversing using ^= in C++
To swap two values a and b, we can write:a = a ^ b;b = a ^ b;a = a ^ b;See https://en.wikipedia.org/wiki/XOR_swap_algorithm for more information. That code is exactly this algorithm, but written in one...
View ArticleAnswer by Ali Tavakol for Heap corruption detected (String makes heap...
The strcat will append to folderName which is problematic. folderName is comming from outside and it might result in memory corruption if you write beyond its allocated storage. See strcat appends to...
View ArticleAnswer by Ali Tavakol for atoi() produces incorrect value when applied to a...
Use strtoll function:timeSlice = strtoll(argv[1], nullptr, 10);
View ArticleAnswer by Ali Tavakol for QStackWidget - Search by name
You may name your stack widgets using QObject::setObjectName function, and then iterate over them to find desired widget using its name, which is QObject::objectName.
View ArticleComment by Ali Tavakol on Typscript error when accessing object's value by...
that's a snippet from a big set of different type of objects, so I can't write any literals. but your second recommendation works well. tnx
View ArticleComment by Ali Tavakol on Typscript error when accessing object's value by...
field is used in a lot of object types and can almost be considered dynamic (but I am sure it is one of the allowed values). that's why I am using let and I can't write any literals.
View ArticleComment by Ali Tavakol on Typscript error when accessing object's value by...
@SvetoslavPetkov works well tnx
View ArticleAnswer by Ali Tavakol for C++ where can I find the implementaion of BOOST_LOG...
I recommend Sublime Text. It is worth the effort and time you put on to learning it. It is fast for navigation and search, and there are plugins like C++11 that direct you to function definitions and...
View ArticleAnswer by Ali Tavakol for how to read a table from oracle database in c++...
You have to add directory of Oracle C/C++ libraries to LD_LIBRARY_PATH environment variable. In my case, it is:export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib:$LD_LIBRARY_PATH
View Article