Skip to main content
Share Your Experience: Take the 2024 Developer Survey
9 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
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
7 votes

QNetworkReply network reply timeout helper

Here are my thoughts: It's a simple class that allocates quite a few times on the heap. You could minimize the number of implicit allocations it does. The ...
Kuba hasn't forgotten Monica'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
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.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

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,757
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
  • 11.8k
5 votes
Accepted

Making modern (RAII) C++-code with Qt5

When in Qt, act like Qt. Qt already has an ownership model, and it works by passing the parent object (as a raw pointer) in the constructor (so there's no window of exception-triggered leakage). And ...
Toby Speight's user avatar
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,502
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
  • 5,996
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,148
5 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,334
5 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
  • 66.4k
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

Modular Visitor Pattern

The visitor pattern and open closed principle. There is a mild conflict here. The visitor pattern is very good when you have a static class hierarchy and just want different ways to traverse the ...
Martin York's user avatar
  • 95.2k
4 votes

Music player written in Python using PyQt

It can be a pleasure to whip something up in an hour on the plane. This code could be improved by using pylint. The most obvious improvements appear to be minimize and structure the instance ...
user650881's user avatar
4 votes

Currency converter using MVC pattern in C++ & QT

I have used a similar approach to implement MVC as you have Mantosh. I would however use references/pointers for both the view and model objects within the controller-class. This would then enable you ...
A.Fagrell's user avatar
  • 141
4 votes
Accepted

My first Qt application - a multiple-state window with a menu

That's a good first Qt program. Most of my comments are preferences rather than rules, but I'll try to provide justifications. In main(), no need to ...
Toby Speight'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.4k
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

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
  • 66.4k
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
  • 57.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
  • 66.4k
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
3 votes

C++ QThread for Oscilloscope/LAN communication

You indentation is not consistent, I'll presume that is a paste error. If not then please fix that, it's much easier to see where functions begin and end when the signature and closing brace stand out....
ratchet freak's user avatar
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
3 votes
Accepted

Reimplemented QAbstractTableModel::setData

...
Mast's user avatar
  • 13.4k
3 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
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

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