12
votes
Moving from Qt/C++ to C#/WPF - Productivity Gain?
Two years later, I'll add an answer myself. This purely reflects my own experience, but might help others in the same situation.
Due to cross-platform availability, I didn't move to C#/WPF but rather ...
12
votes
Accepted
In c++, is there a way inside a function block, to execute cleanup code after the value has been returned?
Addressing the question about cleanup code:
yes, there is a way,
it's called RAII (for Resource Acquisition Is Initialization, an acronym whose limpid clarity is rivalled only by CRTP), and
it is ...
11
votes
Moving from Qt/C++ to C#/WPF - Productivity Gain?
I don't have any experience with QT, but I spent over a decade working with C++ and MFC. I now have almost a decade working with C# and WPF.
I find that I am an order of magnitude more productive in ...
11
votes
Accepted
Moving from Qt/C++ to C#/WPF - Productivity Gain?
I have significant experience with C++ UI development, mostly in Qt but also including wxWidgets and raw win32. I've also done some C# UI development in WPF.
I would strongly recommend literally any ...
9
votes
Accepted
Remove duplicated switch statements caused by not knowing type at compile time of opencv matrix?
Well, if you have the same kind of code multiple times, meaning switch on type-code and then use identical code with that type, how about using a template and generic lambda?
template <class F>...
8
votes
What can I infer from someones code when they use direct initialization with Curly Braces as opposed to Parenthese?
This shows that the author is using modern C++ (e.g. >= C++11) and applies good practice:
Braced initialization is the most widely usable initialization syntax,
it prevents narrowing conversions ...
5
votes
Accepted
When writing a Qt application is good practice to ALWAYS prefer Qt function implementations, data types, and classes when they are available?
If there is an exact equivalent in the C++ standard (like for exact-width types, or math functions), you loose portability to any project not using QT, without gaining anything. And people might ...
5
votes
How to handle custom metadata in XML?
Besides the fact it is a very bad idea to parse XML by regular expressions, I try to answer your questions:
Was XML designed to handle custom metadata?
XML is designed to handle all kind of data ...
5
votes
Accepted
In Qt or C++, is there a good means for creating a switch with dynamically generated cases, or should I just use a for loop (or something else)?
In C++11 or better you could consider using a map of lambdas, e.g.
std::map<unsigned, std::function<void(void)> actmap;
You'll fill it dynamically, e.g.
unsigned num = somenumber();
...
5
votes
Accepted
How to understand and design functions with enumeration arguments that work in tandem with bitwise operators in C++ and Qt?
Your understanding is pretty good. To answer your questions:
Yes, it the function will receive 0x0000 0000 0000 0000 0000 1010 as an argument.
The significance of the decimal number 10 in binary is ...
5
votes
Accepted
Should I always allocate QObject and derived classes to the heap?
The motivation for not putting QObjects on the stack is the Qt ownership model. If an object is destroyed all of its child objects are automatically deleted. If one of those child objects is allocated ...
5
votes
Accepted
How can I emulate Signals and Slots found in Qt, to Javascript / Typescript Classes?
Signals and slots are an implementation of an event system or of the observer pattern. Those are not tied to C++ but can be implemented in any language. Unfortunately, naive implementations of the ...
5
votes
fake filesystem for unit tests
The only thing which comes to my mind is to create needed file structure in a temporary directory and work on it, but that's not a perfect solution
Did you try it? This solution works well for many ...
4
votes
Accepted
How should I structure my C++ project to allow for starting, stopping, and pausing my program?
If it's understood that pauses don't take effect until the current action is finished, then the other parts of the program shouldn't care what the start/stop/pause condition is. They do nothing until ...
4
votes
How to treat in-house libraries
To adress these problems one by one:
check out multiple repositories
Using SVN, you can utilize the "externals" feature for this. This will allow you to define dependencies between different repos ...
4
votes
Accepted
What is the proper way to track my build versions in Qt?
Proper way is:
Have (any possible) Version Control in your project (and forever for all projects)
Instead of rather useless autoincremented counter use any id, provided by VCS of choice
Get this id ...
4
votes
Moving from Qt/C++ to C#/WPF - Productivity Gain?
I've been shared between WPF, Qt, JavaFX years ago, and chose WPF/c#/XAML/MVVM and find it very fast to develop, excellent to maintain, powerful in terms of possibilities and performance; it relies on ...
4
votes
In c++, is there a way inside a function block, to execute cleanup code after the value has been returned?
I guess what you really want is to avoid unnecessary copying of the array. In case you are using a C++ compiler which cannot optimize this automatically by "copy elision" (as mentioned by @amon in a ...
4
votes
Accepted
Do I need to make my code open source or buy a license?
Qt, unless you buy an exception, is licensed as LGPL. This means that whatever modifications you make to Qt has to also be released as LGPL. Your application, on the other hand, does not have to be ...
4
votes
When is Model/View/Controller Too Much?
This seems like a classic case of YAGNI (you ain't going to need it)
You see this a lot with interfaces as well. Devs are told interfaces are good, polymorphism is good and that you should use it.
...
4
votes
Using the same function in two classes?
If you want an example of calling the same function in two different classes without having to define it twice you already have one in the code provided:
self.btn = QtWidgets.QPushButton(self)
...
3
votes
Moving from Qt/C++ to C#/WPF - Productivity Gain?
I learned C#, WPF, MVVM, Entity Framework and probably some more technologies from scratch after I programmed for years with VB6, VBA, SQL and others.
It was a steep learning curve and it took a long ...
3
votes
Merits of copy-on-write semantics
The point is that COW has zero cost when neither copy is changed, and little additional cost when one copy is changed.
Swift uses COW for strings, arrays and dictionaries. Each of these is implemented ...
3
votes
Is it required to disclose source code for custom Qt software?
The GPL requires you to only provide source code whenever you provide binaries. You may opt to provide neither of these. If you provide the customer with the binaries, GPL requires you to distribute ...
3
votes
How to separate serialization, visualization and computation from GUI editable code objects?
As I understand your problem, the interface of each process element is a set of readable and writable properties. A list of (name, value) pairs is all that is needed for both GUI and serialization.
Qt ...
2
votes
Accepted
How to handle custom metadata in XML?
XML is designed to handle arbitrary data. It doesn't distinguish between data and metadata, but does have facilities to allow you to mix data of multiple types defined independently of each other in a ...
2
votes
How to treat in-house libraries
Don't reference other repositories. You have no requirement to build the dependencies every time you build the main application.
Build each library repository into a dll separately and version that ...
2
votes
Accepted
What is the safest practice in handling QWidget pointer lifespan in a QObject oriented environment?
1.
Your linked SO answer just talks about the earliest possible point where such a change could occur. Personally I’ve never seen a proposal or discussion about actually doing something like that.
2. ...
2
votes
Should I always allocate QObject and derived classes to the heap?
The short answer is you should allocate your objects as necessitated by their logical lifetimes. When it comes to asynchronous code, this will be the heap, since multiple functions need to access the ...
2
votes
Architecture/Design for Hardware Control Software
At first glance, the fact that XxxInterface inherits from XxxInterfaceCallback appears strange, until you see that it is done to support the Qt signal/slot mechanism.
Other than that, you appear to ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
qt × 118c++ × 66
gui × 14
python × 9
design × 8
lgpl × 8
design-patterns × 7
multithreading × 7
architecture × 6
programming-practices × 6
licensing × 6
coding-style × 6
mvc × 6
pointers × 5
performance × 4
gpl × 4
pyqt4 × 4
object-oriented-design × 3
programming-languages × 3
android × 3
event-programming × 3
switch-statement × 3
java × 2
object-oriented × 2
algorithms × 2