Qt World Summit: Submit your Presentation

Implications of const signals

  • I noticed that, on occasion, I have need to emit a signal from a const method. I also noticed that there is an easy way to achieve this: You simply make the signal 'const' (at least in Qt 4 that works).

    Later on I realized that I could still connect this const signal to a non-const slot. That also works, but leads to interesting implications:

    Does the const signal tear a hole in the fabric of const-correctness? It certainly looks like it does. Which makes the use of const signals similar to the use of const_cast: There are times when you need it, but you should really think hard what the consequences are.

    What are your views on this?

Log in to reply