Woboq Blog

woboq.com · Company blog · on HN since 2011

Blog of Woboq, a C++ and Qt consultancy, covering Qt internals, moc, C++ reflection, and code browsing tools.

What HN saysCommenters link it on Qt's moc, signals and slots, and C++ reflection, and point to its Rust and QML work as relevant to Qt.
36HN people shared it
22linked it in comments
35stories submitted
779story points
1 year agolast shared
2011people per year2026

Most-shared posts

  1. 1
    Verdigris: Qt Without Moc
    9 people · 172 points · first shared 2016 · 50 comments on HN
  2. 2
    Moc myths debunked
    6 people · 93 points · first shared 2016 · 25 comments on HN
  3. 3
    Can Qt's moc be replaced by C++ reflection?
    5 people · 84 points · first shared 2014 · 27 comments on HN
  4. 4
  5. 5
    How Qt Signals and Slots Work
    3 people · 6 points · first shared 2012 · discussion on HN
  6. 6
  7. 7
    Woboq Source Code Browser Based on LLVM
    3 people · 3 points · first shared 2016 · discussion on HN
  8. 8
    Browsing C++ Source Code on the Web
    2 people · 102 points · first shared 2012 · 15 comments on HN
  9. 9
    C++11 in Qt 5
    2 people · 56 points · first shared 2012 · 12 comments on HN
  10. 10
    Proof Of Concept: Re-implementing Qt moc using libclang
    2 people · 4 points · first shared 2013 · discussion on HN
  11. 11
    Property Bindings and Declarative Syntax in C++
    2 people · 4 points · first shared 2013 · discussion on HN
  12. 12
  13. 13
    C++14 for Qt programmers
    1 people · 60 points · first shared 2014 · 1 comments on HN
  14. 14
    Data initialization in C++
    1 people · 58 points · first shared 2013 · 17 comments on HN
  15. 15
    QWaitCondition: Solving the Unavoidable Race (2014)
    1 people · 38 points · first shared 2021 · 8 comments on HN

What HN people wrote when they linked it

jcelerier · 2018-06-09
cool :) Are you aware of Olivier Goffart's take on QML in Rust ? https://woboq.com/blog/qmetaobject-from-rust.html ; it seems that it could maybe be used instead of the custome code-gen you did. That's a great time for Qt and Rust, no doubt :p
guruz · 2016-03-07
Thanks everyone for the upvotes :) Right now we're wondering how to make a bit of money out of this. Do you have any hints or recommendations? (consulting/contract work is the main income for the company currently) Current license and price: https://woboq.com/codebrowser.html#license
green7ea · 2015-10-26
I'm very sad to see that reflection (or introspection) won't be making an appearance in c++17. Even limited introspection suggested in N3951 (http://woboq.com/blog/reflection-in-cpp-and-qt-moc.html) would be a great boon. Implementing features that would render Qt's preprocessor useless would be a great start and would standardize the tooling around c++ as well as reducing the amount of boilerplate code required to do something as simple as serialization.
martin_ky · 2018-06-20
> With Qt you get a lot of conveniences and built-in magic, but I'd say at that point it's not really regular C++. This is a common misconception of beginner Qt users or people who just looked at Qt superficially and decided not to use it, because it's not "regular C++". You use Qt with 100% pure C++. Qt itself is written in 100% pure C++. The part that confuses people is the metaobject compiler (or MOC). This is a simple code generator tool that provides additional features like runtime type information and reflection. It does not modify your source code, only generates some additiona, 100% legal C++. Granted, this requires an extra build step before invoking the C++ compiler. But Qt's build system handles this automatically, and it's not really difficult to integrate into any other build system. Starting with Qt 5, you don't even need to invoke the MOC compiler, because in many cases, the features provided with generated code were replaced by new C++11 functionality. If/when C++ gets proper metaclasses and programmable compile-time code generation, there will be no more need for MOC, because all of its functions can then run in a single compilation step. There's a great blog post debunking the myths about the QT metaobject compiler - https://woboq.com/blog/moc-myths.html
iheartmemcache · 2017-01-26
So this is where I'd start[0]. Their site has amazing documentation. I personally found Qt even in the KDE2 days miles better than React/Redux and non-Smalltalk MVC's. Since then it's only gotten better. Check out the examples here[1], the diving in section here[2], the book here[3], Stackoverflow has an overview of the whole system here[4]. You emit signals. Slots consume them. QObject::connect links the two. Queues are just queues in the traditional MQ sense. You don't use them in for, say, local GUI controls since it's generally a 1-1 unidirectional link (and if it's bi-directional, although I rarely need to do this, just ::connect( a,b,SLOT(),SIGNAL() ) then ::connect( b,a,SLOT(),SIGNAL() ). If you're still having problems read this[5]. If you have issues, that blog also has a preceding page which has a comprehensive analysis of the underpinnings of the entire slot/signal system in QT. If you still have problems, get on IRC and someone will give you a hand. If you're having a major issue, contact me. If it's a quicky I'll lend a hand, if not I know a few absolutely spectacular HN engineers who I'd recommend in a heartbeat. I'd be real curious as to what's you consider 'messy' about signals/slots is you're having re: slots/signals (I guess since I've used Moose's MOP with Perl 5 and CL they sort of came naturally to me). I have no affiliation with Trolltech/QT/Nokia/whoever-owns-whatever-now at all; I just think C++ is real easy to mess up, libraries are even easier…
ogoffart · 2025-10-12
10 years ago, in another life, I was already experimenting with trying to provides feature from moc with reflections and from other macros: - https://woboq.com/blog/reflection-in-cpp-and-qt-moc.html 2014, That was based on a previous reflection proposal - https://github.com/woboq/verdigris : 2016, Replaces the moc by a set of macros. What my verdigris experience shows is that it is perfectly possible to replace the moc at the cost of slightly uglier macros. And this was using C++14. I haven't look in details at the C++26 reflection, but I'm sure it would make it easier to make these macro more pretty.
shkurski_ · 2024-07-02
moc can be replaced without reflection: https://woboq.com/blog/verdigris-qt-without-moc.html
saidinesh5 · 2023-11-23
There were a couple of attempts in that direction, but i haven't really seen them used in any production codebase. https://woboq.com/blog/verdigris-qt-without-moc.html
__s · 2020-12-13
There are many applications that still need the general purpose of CPUs while being vectorized See libjpeg-turbo, ffmpeg, crypto, hashing in general, ripgrep, simdjson, ... https://woboq.com/blog/utf-8-processing-using-simd.html See also: https://www.reddit.com/r/compsci/comments/4cq0ls/when_is_simd_better_t… If simd was obsoleted by GPUs intel & amd wouldn't keep introducing wider simd extensions
kevsim · 2020-12-08
There was some effort to make it possible to use Qt without moc [0] and instead rely on some more modern C++ features. No clue where the effort is these days 0: https://woboq.com/blog/verdigris-qt-without-moc.html
likeliv · 2019-12-31
You seem to misunderstand what moc does. This page should help you: https://woboq.com/blog/moc-myths.html Moc just adds some more generated code next to you valid C++ code, generally in a new translation unit. That generated code is just boiler plate which you could write by hand if you wanted. In a sense this is what verdigris does: it provides macros that makes makes it easier to "write it by hand" (the W_OBJECT_IMPL macro somehow expends to the code generated by moc)
chubot · 2017-06-22
Hm does anyone know of a web-based tool like this that uses Clang as a back end? I want to put open source code like the bash and Python interpreters in it and be able to navigate symbolically. And I want nice permalinks. EDIT: It looks like https://woboq.com/codebrowser.html is what I want. The code available but not under and open source license. https://github.com/woboq/woboq_codebrowser/ I will probably try this, but I'm interested in alternatives!
dkersten · 2016-06-23
It pretends to be c++ but it doesn't support all features It IS C++ though. All of the moc keywords are just macros (that the moc happens to interpret otherwise). signal: is just `#define signal public` and so on. You could compile annotated code without moc without issues. Signal/slot connections are also compile-time type checked if you use the Qt 5 function pointer syntax: https://woboq.com/blog/new-signals-slots-syntax-in-qt5.html I won't comment on the rest of what you say, as I don't really know enough about it.
i336_ · 2016-06-22
While I'm not 100% on Qt's history, some quick Googling finds references that suggest moc was around in the Qt2 days, which was 1999, which was before even C++03 was a thing. So it's mostly a historical relic, now hidden away as much as possible by things like automoc in cmake. Also, FWIW, moc-ng is based on libclang, which looks to be vaguely in the general direction of what you're getting at: https://woboq.com/blog/moc-with-clang.html
symlinkk · 2016-06-16
Do you have a link that shows how to compile a Qt app without moc? I looked specifically for this and could only find this, which is unofficial and contains a bunch of ugly macros: https://woboq.com/blog/verdigris-qt-without-moc.html
malkia · 2016-03-16
Seems like it's matching Visual Studio :) - https://woboq.com/blog/qdockwidget-changes-in-56.html Awesome job Qt folks!
distances · 2016-03-16
Lambdas can be used e.g. with the new signal-slot syntax [1]. And yes, Qt uses the meta compiler, and it's hopefully going to stay that way as moc has a clear positive impact both on features and speed [2]. [1] https://wiki.qt.io/New_Signal_Slot_Syntax [2] https://woboq.com/blog/moc-myths.html
shawn-butler · 2012-12-20
The new syntax would not as type safety is being enforced at compile time. However the old syntax using strings is also available so if it is, then yes used the same preprocessor macro step will apply. Was reading to find answers to some of my own questions and found this link helpful regarding use of c++11 in Qt5 [0]. Use of c++11 features seems limited in the first release which makes sense. [0]: http://woboq.com/blog/cpp11-in-qt5.html
thamer · 2022-03-20
With Qt you don't really have to deal with unexpected messages. A signal is triggered by an event, like a button click or a slider value changing, a checkbox being toggled, this kind of thing. A slot is just a place to receive it, it's a regular function or method with a compatible signature for the kind of event it's meant to process. There are no unexpected calls because you have to explicitly connect a signal to a slot, something like: QObject::connect(&button, &QPushButton::clicked, &mainWindowController, &MainWindowController::onButtonClicked); If no slot is connected, the signal just doesn't go anywhere. Something that's special with Qt is that signals and slots are declared in the class using custom syntax, e.g. slots: void onValueChanged(int value); signals: void valueChanged(int newValue); Yes here "signals:" and "slots:" look like the same kind of keyword as "public:" or "private:" in a class declaration, even though internally they're #defined as "public:" and "/**/" respectively. Qt makes use of a tool called MOC – the Meta Object Compiler – to generate code for signals and slots. It's not a pre-processor but a code generator, which has to run before you can actually compile the code. I think you could probably implement a similar system of event subscriptions without this additional code generation step. See this page for details: https://woboq.com/blog/how-qt-signals-slots-work.html
oever · 2018-06-09
Rust Qt Binding Generator is for projects that contain Rust and QML or Rust and Qt widgets. The GUI code will be in the native language for Qt: C++ or QML. The data model underneath and any non-UI parts can be written in Rust. This approach was chosen because it's hard to wrap Qt Widgets (let alone QML) safely in a Rust API. Generating binding code is a very pragmatic approach that works now. You do not need external libraries, just generate some code, include it in your project and use qmake/cmake/... and cargo together. I've explained this approach in a presentation at FOSDEM [0]. That being said, there might well come a better solution that manages to wrap Qt and the mechanisms of deriving from Qt model classes in a Rust API. It may even manage to require only Cargo as a build tool. In fact, only yesterday Olivier Goffart presented a prototype that does just that. [1] And that project has the exact same to-do application in its examples with only Rust and QML (no JSON or C++). Switching between those approaches should be very simple though. Especially since Rust has static typing which makes refactoring a breeze. [0] https://fosdem.org/2018/schedule/event/rust_qt_binding_generator/ [1] https://woboq.com/blog/qmetaobject-from-rust.html
kuschku · 2018-03-12
Especially when used in the core/client split version, which allows you to use the webclient https://github.com/magne4000/quassel-webserver/, the irssi-client https://github.com/phhusson/quassel-irssi, the iOS client https://woboq.com/iquassel.html, the Android client https://play.google.com/store/apps/details?id=com.iskrembilen.quasseld… or https://f-droid.org/packages/com.iskrembilen.quasseldroid/, the new alpha of the new android client https://quasseldroid.info/, and the fulltext search https://github.com/justjanne/quassel-rest-search (with demo here: http://s3.kuschku.de/public/quassel-rest-search.mp4 ) Quassel alone is a kinda nice client, with the entire ecosystem around it, it becomes amazingly powerful. And the beauty of the Qt client is that, being Qt, you can fully style it with css - e.g. https://bugs.quassel-irc.org/projects/quassel-irc/wiki/Stylesheet_Gall… Disclaimer: I contribute to some of the above mentioned projects)

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close