Qt - Reddit
15 subscribers
280 photos
46 videos
4.22K links
News and discussion for the Qt Framework.

Subreddit: https://www.reddit.com/r/QtFramework

Powered by : @r_channels & @reddit2telegram
Download Telegram
Is name Qt from initials of Quasar Technologies?

I saw the Qt timeline that the Qt project was started first and then it's creators Haavard Nord and Eirik Chambe-Eng registered the 1st company called Quasar Technologies, but is that what they had in mind when they started the project, Quasar Technologies, as a project and then they just used the initials Qt?

Does anyone know for sure?


https://redd.it/1snaicv
@qt_reddit
Opinions and advice on futureproofing when going c++/MFC > net/avalonia or c++ > c++/QT

Original post in:
https://www.reddit.com/r/dotnet/comments/1sp5mln/opinions\_and\_advice\_on\_futureproofing\_when\_going/
somehow crossposting didn't worked here

I maintain a quite large codebase that is c++ with MFCs as the GUI and for other system relevant stuff (Databases, Filesystem etc) that is partially 30-40 years old and still runs fine but is up for a larger / very large rework. Also a factor: European, so unsure about the future with 100% US products, customers going "no windows!", governments ditching MS, etc

Background:

Why post in r/dontet and others?
I consider switching to net because development speed is about 10 times faster, especially with GUI libs like AvaloniaUI for example and you get cross platform more or less out of the box "for free" included. And the looks are quite better.

The ressource hog of .net is brutal though. POCs have about 10-20x more RAM use then the proven c++ base while only covering below 20% of the features.

What I am concerned in is that, as I understand the .net economy, that is still quite MS depended in how it will live on and that whatever you write needs to be completely maintained to compatibillity with the then current runtime. And if MS kills off the runtime or a feature you depend on you have to start all over. So the vendor lock in into MS stays - as a windows software that was a normal thing but on multi platform...
Now it's runtimes from MS, GUI from Ava, OS runtime Support for the OS one decides to support, a lot of vendors that can kill your day. MFC stuff from Win95 (that was 30 years ago) still works without maintenance.

The other idea is going c++/QT but the dev speed is about 1/10th of net and that could just be too much on the other hand a lot of old code could be reused and it can be rolled over gradually, and that may cut the time into a batch that is manageable. With .net its a complete rewrite. Would loose the vendor lock in of MS but would gain the QT lock.

No one knows for sure but at the moment I miss my usual gut feeling about loglivety of ecosystems and the tripple+ vendor lock in is unnerving.

I fear that saving time and complexity now instead of staying c++/MFC or using something like c++/QT (what if QT abadons features or Operating Systems or closes it's doors in 10 years?) may hit me like a brick wall at lightspeed in a decade or two.

What are your thoughts of the safety / risk of an ecosystem change?

How stable and long living your gut says .net is?

Are there other options I don't see at the moment?

https://redd.it/1sp5rkz
@qt_reddit
This media is not supported in your browser
VIEW IN TELEGRAM
[Qt Quick3d] Weekend, and I felt the urge to tinker with the water shader 🌊

https://redd.it/1sp8m2j
@qt_reddit
Did I misunderstood a code segment or is it just nonsense?

I was trying to learn reason for a bug in qBittorrent and have stumbled onto this file. It seems like constructor sets variable m_storeSmartEpisodeFilter to instance of QString, and then this method tries to .get() filter from it, but as far as I can tell from documentation it doesn't have that method, and even if it did, it would just spit out RSS/AutoDownloader/SmartEpisodeFilter.

I don't have much knowledge in C++ or qt in particular, so maybe it does something that I don't understand.

https://redd.it/1spwa2m
@qt_reddit
Why you can't just "forget" raw pointers in Modern C++/Qt (and why smart pointers might crash your app)

Modern C++ (11/14/17/20...) has a very clear mantra: *"Forget* `new` *and* `delete`*, use smart pointers."* It’s excellent advice for pure C++. But the moment you open the Qt documentation, raw pointers (`T*`) start jumping at you from every page.

Why is it that even in 2026, you can't write a serious Qt application using exclusively smart pointers? Let’s look at where "smart" code actually breaks the framework’s logic.

# 1. The Ownership Conflict: Parent-Child vs. Smart Pointers

Qt’s core feature is the **Object Tree**. When you pass a parent to a `QObject` constructor (like a `QWidget`), you are delegating memory management to that parent.

**The "Double Free" Trap:**

Imagine trying to be "modern" and using `std::unique_ptr` (or `QScopedPointer`) where a parent already exists:

void createUI(QWidget* parent) {
// Ownership is passed to parent, BUT unique_ptr also thinks it's the owner
auto label = std::make_unique<QLabel>("Hello", parent);
// ... logic ...
} // unique_ptr goes out of scope and calls delete.

**What goes wrong?**

1. `unique_ptr` honestly deletes the object when the function ends.
2. However, the `parent` still keeps a pointer to this label in its internal `children()` list.
3. When the `parent` is eventually destroyed (e.g., closing the window), it tries to delete the already-deleted label.
4. **Result:** Crash / Double Free.

Smart pointers implement static or reference-counted ownership. They simply aren't aware of `QObject::parent()`.

# 2. The Chaos of GUI Lifecycles and QPointer

In GUI apps, object lifetimes are often unpredictable. A button might be deleted because a tab was closed, a dialog was dismissed, or a server signal was received.

If you need to store a reference to an object you *don't* own:

* `std::shared_ptr` won't help (it will keep the object alive when it should have died).
* `std::weak_ptr` only works with `std::shared_ptr`.

Enter `QPointer<T>`. This is Qt’s unique "weak" pointer. It doesn't own the object, but it **automatically turns to** `null` when the target `QObject` is deleted (via `delete` or by its parent). It does this by subscribing to the `destroyed()` signal. You can't achieve this safety with standard smart pointers without fighting the framework.

# 3. QML and the JavaScript Garbage Collector Trap

If you use QML, the pointer situation gets even weirder. When you pass a `QObject*` from C++ to QML, `QQmlEngine::ObjectOwnership` kicks in.

If a C++ object has no parent (`parent == nullptr`), the JavaScript engine might decide **it** owns the object. When the JS Garbage Collector (GC) sees the object isn't used in QML anymore, it deletes it. Your C++ pointer becomes a dangling "bomb" that will crash your app later. Smart pointers are powerless here; they can't control the JS GC.

# 4. Performance and Low-Level API

When working with `QImage::bits()` or OpenGL contexts, you need raw memory access.

uchar* scanline = image.scanLine(y);
for(int x = 0; x < width; ++x) {
// Direct memory access is the only way to hit 60 FPS
scanline[x] = process(scanline[x]);
}

Any smart pointer overhead inside such loops would kill the performance benefits of C++.

# The "Qt Memory Management" Cheatsheet

To avoid losing your mind between two systems, follow these rules:

1. **Creating a QObject with a Parent?** Use a raw pointer. The parent will handle it. `new QLabel("Text", this)` is perfectly fine.
2. **Creating a QObject WITHOUT a Parent?** Use `std::unique_ptr` or `QScopedPointer`. This prevents leaks.
3. **Need to track an object you don't own?** Use `QPointer`. It’s the only safe way to check if a widget is still alive.
4. **Non-QObject (Business Logic)?** Use `std::unique_ptr` (ownership) or `std::shared_ptr` (shared resources).
5. **Passing objects to QML?** Always set a parent or explicitly call `QQmlEngine::setObjectOwnership(obj, QQmlEngine::CppOwnership)`.
6. **Multi-threading?** Use `QSharedPointer`. It’s
the "native" Qt way to handle thread-safe ref-counting.

# Conclusion

Writing a Qt app is a balance between classical RAII and hierarchical ownership. Trying to use *only* smart pointers is a fight against the framework. Understand where Qt takes responsibility and where it leaves it to you, and your code will stay crash-free.

**TL;DR:** Qt's parent-child system and QML's garbage collector manage memory in ways that conflict with `std::unique_ptr`. Raw pointers are still "first-class citizens" in Qt, provided you understand the ownership rules.

https://redd.it/1ss960j
@qt_reddit
A question regarding Qt for Linux, GCC vs pure Clang ambiguity.

This is regarding edge case scenarios related to correctness.

Official 'Qt for Linux' guide doesn't mention clang or LLVM anywhere. It's all GCC in there.

Are the Qt libraries carefully designed around the GCC specific compiler intrinsics and shits and GNU's implementation of Standard Template Library that it can not be safely built with the pure Clang toolchain and used for serious use cases?

Pure clang is significantly faster to compiler, it can integrate with even faster 3rd party linkers as well. Binaries are noticeably smaller due to libc++ being 10x smaller.

I mean does the Qt have some kind of personal relationship with libstdc++ that we can't link it with libc++?

https://redd.it/1ssl9pz
@qt_reddit
PySide 6.11 doesn't build on macos

When trying to build PySide 6.11 it always gives this issue

[ 14%\] Building CXX object PySide6/QtCore/CMakeFiles/QtCore.dir/PySide6/QtCore/qdirlisting_wrapper.cpp.o

pyside-setup-everywhere-src-6.11.0/build/pyside6/PySide6/QtCore/PySide6/QtCore/qdirlisting_wrapper.cpp:152:86: error: no type named 'Default' in 'QDirIterator::IteratorFlag'

::QFlags<QDirIterator::IteratorFlag> cppArg1(QDirIterator::IteratorFlag::Default);

\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\^

pyside-setup-everywhere-src-6.11.0/build/pyside6/PySide6/QtCore/PySide6/QtCore/qdirlisting_wrapper.cpp:168:86: error: no type named 'Default' in 'QDirIterator::IteratorFlag'

::QFlags<QDirIterator::IteratorFlag> cppArg2(QDirIterator::IteratorFlag::Default);

\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\^

pyside-setup-everywhere-src-6.11.0/build/pyside6/PySide6/QtCore/PySide6/QtCore/qdirlisting_wrapper.cpp:232:44: error: no viable conversion from 'QFlags<IteratorFlag>' to 'QFlags<QDirIterator::IteratorFlag>'

QFlags<QDirIterator::IteratorFlag> cppResult = const_cast<const ::QDirListing *>(cppSelf)->iteratorFlags();

Shiboken6 and Shiboken6 generator build fine it only gives this error when building PySide6

On linux it built smoothly

Any ideas on what could be wrong?

Versions:

shiboken6= 6.11.0

Pyside6 = 6.11.0

Qt = 6.11.0

Compiler = tested with AppleClang 14, 16, 17

LLVM = tested with llvm14, llvm18 and llvm22

Macos 14 x86_64 and macos 26 arm64

Even following every step from the official guide results in the same error

https://doc.qt.io/qtforpython-6/building_from_source/macOS.html

https://redd.it/1sus0hu
@qt_reddit
Qt Creator + CMake on Windows is driving me insane (need help)

I’m honestly losing my mind over this and I’m hoping someone here can tell me what I’m doing wrong (or confirm that this setup is just cursed). I’m required to use Qt Creator (Qt 6.11, MinGW 64-bit) for a university course. We’re just supposed to build simple C++ programs (console + later small GUI/game stuff). Nothing crazy. But the environment is completely unstable for me.

Typical experience; I create a new project, first run works fine. Second run... suddenly: “No executable specified in run configuration” or CMake completely breaks (wrong paths, cache pointing to old directories). If I move or rename the project folder ONCE, everything is broken. Build folders seem to corrupt everything. CMakeCache points to directories that don’t even exist anymore and Qt Creator sometimes doesn’t show files correctly or ignores changes. On top of that: Windows (Smart App Control / Defender) randomly blocks my compiled .exe files so, I constantly have to unblock or disable things just to run my own code

Things I’ve already tried: reinstalling Qt multiple times, using different kits (MinGW, LLVM, sticking to MinGW now), deleting build folders and reconfiguring, creating fresh projects from scratch. And still after a short time its broken again.

What I actually want is a simple workflow where I can write code, press build, run program, That’s it.

My questions are:

1. How do you actually use Qt Creator + CMake without it constantly breaking?
2. Is it normal that you basically must NEVER move a project because of CMake?
3. How do you deal with Windows security blocking your own compiled executables?

At this point I’m spending way more time fighting the tooling than actually programming, and it’s killing all motivation. I just dont know what to try anymore and I just want this to work.

Any help or advice would be massively appreciated 🙏

https://redd.it/1sv8ikw
@qt_reddit
Weird QFont and QLabel behaviors

Hi everyone,

I ran into a font rendering inconsistency between QLabels with weird conditions.

Here's a minimal example of my app UI. I thought it was only on the app I'm currently working on, but it seems it's the same in this project too.

So I'm using Segoe UI font (which comes by default on Win 11, what I'm currently on) and I set it to my QApplication, and then retrieve it in MainWindow setupUi method, increment the pixel/point size and set it to my QLabels, but the text rendering is incorrect:

Red underline is added with Paint

The weird part is when I comment the first title setFont here, the rest renders correctly:

Red and green lines added with Paint, first title setFont is commented

Did anyone run is a similar situation or am I missing something about QFont usage, or some clash with QLabels ? Advice or even deeper explanations are more than welcome.

Thanks in advance

https://redd.it/1sxphau
@qt_reddit
Missing add definition in cpp

Since the latest update (17.0.0) I've been missing the option to generate a function in the cpp file, only the option to generate Outside or Inside class are showing, and it's driving me kinda crazy, I rolled back to 16.0.2 but it still happens

https://preview.redd.it/u9htik5idrcf1.png?width=274&format=png&auto=webp&s=82882e700575782c07137274b39fd8b095ddc221




https://redd.it/1lzby8f
@qt_reddit
The current state of QT3D and whether it's worth using

It's still included in the package—it's very useful, but it's marked as deprecated. I'd like to use it for a game built with QT; it's convenient because I'd also like to use it within a widget in my level editor, and that can be done in Python rather than QML.

https://redd.it/1t1f2iy
@qt_reddit
Questions about client-server app idea

I have an idea for an client-server app that consist of:

1 .A "client" for a touch screen device (e.g. tablet) that shows a bunch of "widgets" written in qml that interfaces with so called "modules", consisting of C++ code that send messages to the host

2. A "host app" that manages the client UI and receives messages from client that also has "modules" that interface with host's apps.

An example is a media controls "module" on both host and client and its respecting "widget" that is the UI on the client.

I have a few goals for this idea:

1. There can be different "widgets" that interface with a client module. A single widget can be full screen and can interface with multiple client modules.

2. Host modules expose a preferences menu to the host app to configure .

I have some questions about implementing this idea.

1. Should I separate the backend and frontend (ui) for the host app, where the backend does not use qt? This approach allows multiple frontends using different toolkits, but since i am going to use qml for the client ui anyway and client modules have to use qt specifics, i was thinking otherwise.

2. Should I have host modules not rely on qt specific stuff (slots, properties) for the logic, or use it? This helps with achieving the idea from question 1.

3. Boost.asio or qt network for communication between both host and client?

4. Client modules using c++ or qml based interface that interfaces with both widgets and the client code (especially sending messages to host)?

https://redd.it/1t1ol0a
@qt_reddit
Media is too big
VIEW IN TELEGRAM
Wrote 360 Video Player in Qt (PySide6) and PyOpenGL

https://redd.it/1t1xcpr
@qt_reddit
AstroCore G-Code Sender - Qt 6 - looking for help
https://redd.it/1t2iawb
@qt_reddit
CodePointer version 0.1.4 - new C++ IDE/editor

May release (named Fist my bump) is released. While the changelog is not large, a new huge feature was used: tree-sitter support. This means that C++ completion is "kinda" usable, with semantic support. It will fail in many edge cases (as the code is just parsed not evaluated), only for your code (not system libraries) - but it is very helpful.

One useful feature of this IDE is its low memory footprint, currently I see its using bellow 300 MB while 2 projects are loaded on Linux (Windows has similar memory footprint):

 364884 AppRun           /home/diego/Downloads/codepointer-v0.1.4-x86_64.AppImage                       5 diego       269M ⣀⣀⣀⣀⣀  0.0  

CodePointer editing its own main.cpp


Binary packages are in https://github.com/codepointerapp/codepointer/releases/tag/v0.1.4

Code is available at:
https://github.com/codepointerapp/codepointer
https://gitlab.com/codepointer/codepointer/



https://redd.it/1t2tkel
@qt_reddit
This media is not supported in your browser
VIEW IN TELEGRAM
Glitchy/shaky movement of text/items when rendered on a display with fractional scaling

https://redd.it/1t37zoz
@qt_reddit