Skip to main content
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 ...
Toby Speight's user avatar
  • 88.3k
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: ...
J_H's user avatar
  • 42.1k
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 ...
G. Sliepen's user avatar
  • 69.3k
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: ...
200_success's user avatar
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: ...
Toby Speight's user avatar
  • 88.3k
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 ...
Joel's user avatar
  • 176
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 ...
Summer's user avatar
  • 2,360
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 ...
Deduplicator's user avatar
  • 19.9k
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 ...
Edward's user avatar
  • 67.2k
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 ...
papagaga's user avatar
  • 5,817
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 ...
user673679's user avatar
  • 12.2k
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. ...
G. Sliepen's user avatar
  • 69.3k
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 ...
Snowhawk's user avatar
  • 6,770
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. ...
Josiah's user avatar
  • 6,106
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 ...
R Sahu's user avatar
  • 3,572
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 ...
TrebledJ's user avatar
  • 437
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, ...): ...
Martin Hennings's user avatar
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 ...
JDługosz's user avatar
  • 11.7k
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 ...
ratchet freak's user avatar
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 ...
Harald Scheirich's user avatar
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 ...
Edward's user avatar
  • 67.2k
4 votes
Accepted

Create HTML structure dynamically

Avoid explicitly constructing QString and QStringLiteral objects In many cases, it's totally unnecessary to explicitly write <...
G. Sliepen's user avatar
  • 69.3k
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 ...
Edward's user avatar
  • 67.2k
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 ...
G. Sliepen's user avatar
  • 69.3k
3 votes

A moveable QScopedPointer, or a Qt and std cross-compatible unique_pointer

Congrats, and good luck with your endeavors. ...
JDługosz's user avatar
  • 11.7k
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....
Toby Speight's user avatar
  • 88.3k
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 ...
Toby Speight's user avatar
  • 88.3k
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 ...
Zeta's user avatar
  • 19.7k
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: ...
Toby Speight's user avatar
  • 88.3k
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 ...
Toby Speight's user avatar
  • 88.3k

Only top scored, non community-wiki answers of a minimum length are eligible