10
votes
Thread pausing/resuming/canceling with Qt
The code you have is unsafe, because pause() and cancelWork() are called from outside the worker's thread, and they use no ...
9
votes
Rotary Encoder Controller C++
magic number
I think that MAXLINE dictates your buffer size,
and that for parallel construction with the recv()
we wanted sizeof(buffer) here:
...
9
votes
Rotary Encoder Controller C++
In addition to what J_H already mentioned:
UDP is not reliable
UDP does not guarantee that if a message is sent, that it will be received exactly once by the other side. Sometimes that's fine; if you ...
8
votes
Accepted
Parser for STL stereolithography data files
Well, it's not much of a mystery. Your code is simple and pretty. Their code is ugly because it performs exactly what it needs to do, and no more:
...
6
votes
Accepted
Safely and elegantly handling UNIX signals in Qt applications
I did something similar a while ago. Instead of one singleton that handles all signals, I found it easier (for the caller) to have one object per signal:
...
6
votes
Accepted
Age in hours calculator
It looks like you're manually trying to calculate the amount of hours since birth, which will be difficult because of leap years and the general difficulty of working with dates. I would recommend ...
6
votes
Accepted
Simple postfix calculator app
Disclaimer: I'm not familiar with Qt
With that in mind I still have some points I can mention.
My worry is that this approach may be inefficient, given how many
variables a State has and how long a ...
6
votes
Accepted
A moveable QScopedPointer, or a Qt and std cross-compatible unique_pointer
Well, how about a radical idea:
Just use std::unique_ptr, the only extra-capability yours has is .addressOf(). Yes, you might ...
6
votes
GUI Number Generator in QT C++
I see a number of things that may help you improve your program.
Use proper case for file names
We all know that Windows is not case sensitive with respect to file names, but pretty much every other ...
6
votes
Accepted
Filter for CANbus frames
Cleaner and clearer it can certainly be:
your function is called isFrameMatchedByFilter but returns true if there is no filter in the filter list: does that mean ...
6
votes
Parser for STL stereolithography data files
Note that we don't have a fully-compilable program, or the example data. But you do! So you can actually measure what's taking up the time using a profiler.
However, I would guess that the following ...
6
votes
Splitting a long introduction into collapsible elements easier to read and translate
Create collapsibles in HTML/CSS/JS
At best I would like these texts to live outside the code logic, but I did not accomplish that, yet.
I would strongly recommend you try to achieve this goal first. ...
5
votes
Accepted
A simple Fraction class
#ifndef FRACTION_H
#define FRACTION_H
Your guard name is vulnerable to collisions. Append more information and a good differentiator to reduce the chance a ...
5
votes
A simple Fraction class
One thing that would help simplify your implementation is to fall back to already implemented code. For example, you could implement subtraction as addition using the negative of the second fraction. ...
5
votes
Accepted
Using QXmlStreamReader to read configuration file of key-value pairs
Case for not using a class
It's not clear to me whether you need a class for what you are doing. Unless you need to be able to construct an instance of ...
5
votes
Accepted
Qt Number Generator v2
Seems like you've made a lot of improvements since your previous post! Let's get into the review!
1. General Overview
a. Use the ...
4
votes
Thread pausing/resuming/canceling with Qt
You're not locking m_continue before waiting with it.
From the docs of QWaitCondition::wait(QMutex *lockedMutex, ...):
...
4
votes
Plotting a GPS track
Don’t write using namespace std;.
You can, however, in a CPP file (not H file) or inside a function put individual ...
4
votes
Accepted
C++ Qt simple GUI game
When dealing with Qt 5+ prefer the new connect syntax:
QObject::connect(ui->tiles01, &QPushButton::clicked, this, &MainWindow::tileCliked);
Instead of ...
4
votes
Accepted
GUI Number Generator in QT C++
your first statement is that you want advice in naming conventions and in your second line you state
I know that you should NOT use _ prefix, but I really like it and m_ looks ugly to me.
Some ...
4
votes
Accepted
C++ Snake game using Qt-framework
Here are some things that may help you improve your program.
Use consistent formatting
It appears that your code uses tabs in some places and spaces in others, making the code appear badly formatted ...
4
votes
Accepted
Create HTML structure dynamically
Avoid explicitly constructing QString and QStringLiteral objects
In many cases, it's totally unnecessary to explicitly write <...
4
votes
Accepted
Hunt the Wumpus Game (C++ with QT)
In all this is a good effort and helped me discover and report a bug in mutter, so I learned some things, too. There are still some things that I think can help you improve your program.
Fix the bug
...
4
votes
Accepted
Do a thing with a derived string for a number of strings
Just try implementing your ideas
I feel this should be possible more concisely, less code repetition, with a loop and a two-dimensional array or something. But not sure how exactly.
You have the ...
3
votes
A moveable QScopedPointer, or a Qt and std cross-compatible unique_pointer
Congrats, and good luck with your endeavors.
...
3
votes
Using QXmlStreamReader to read configuration file of key-value pairs
Your code looks to be about the expected level of complexity for the task. I wouldn't attempt to reduce it any further - you're unlikely to make it faster, and definitely likely to hinder its clarity....
3
votes
Accepted
C++ with Qt - Conversion of angle in radians to DDD°MM′SS.FFF″ string
Nice code - easy to read and well laid out. No surprises in the code, apart from the need to clear up the carry from seconds to minutes etc.
Some small improvements:
Although ...
3
votes
Accepted
RubberDucky Detector
You have a data race in your code. You access running reading and writing. volatile does not mean threadsafe. Therefore, your ...
3
votes
Sharing file descriptor between an under-privileged and a privileged process (using C++ and Qt)
Headers
You don't actually need <QSocketNotifier> in the public header; a forward declaration is enough:
...
3
votes
Currency converter using MVC pattern in C++ & QT
Intro
You have a good review of your structure and its relation to the MVC pattern from Martin York, so I won't reiterate those points. Instead, I'll look at a lower level for some improvements to ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
qt × 128c++ × 117
gui × 15
python × 10
object-oriented × 9
c++11 × 8
c++17 × 8
beginner × 7
multithreading × 7
c++14 × 6
qml × 6
performance × 4
strings × 4
calculator × 4
mvc × 4
pointers × 4
pyqt × 4
python-3.x × 3
json × 3
memory-management × 3
template × 3
opengl × 3
algorithm × 2
game × 2
html × 2