Qt: More slots please

I’m usually an avid fanboy of Qt, but the more I use it, the more I find myself wanting two changes:

1. More slots please
2. More control over signals 

Read on for a couple examples.

1. More slots please

It would be great if QComboBox’s setCurrentText() were a slot. Then I could hook combo-boxes to eachother. I realize that Qt 4 has refactored the setCurrentText() method to require an index too, so this will probably not happen, but it would be helpful.

I would also like QScrollBar to make setMaxValue() a slot. That way I could hook my custom widgets’ maxHScroll() and maxVScroll() signals to it instead of having to write one-liner slots for the sole purpose of passing values straight through to setMaxValue().

2. More control over signals

I always have to guess whether a certain method call will result in a signal being fired. For example. Does QLineEdit::setText() emit a signal? What about QSpinBox::setValue()? What about QCheckbox()? (answers below)

Wouldn’t it be nice if there were two ways to call QLineEdit::setText(): One that would emit the textChanged() signal and one that would noy? Or better yet: just make setText() always emit textChanged()!This would save me lots of headache. I like the way that QSpinBox and QCheckbox do it. They emit valueChanged() and toggled() whether the user clicks on them or their values are changed programmatically.

I would also like to see a textChangedFocusLost() signal for QLineEdit. As is, I have to manually track whether the text has really changed with my own boolean and the textChanged() signal. Then, on lostFocus() I check that boolean, and if true, I finally know that the text was changed. When you’ve got a dialog with a couple dozen QLineEdits, that’s a lot of booleans to keep track of!

Could there be a way to retrieve a list of connections for a widget? It would be nice to know what connections a widget has before mucking with it. That way, I could remove connections, make changes, and restore them at runtime if need be.

Enough rants for one evening. I love Qt. It works far better for me than any other widget toolkit that I’ve used. It’s fast, pretty, cross-platform (yes, it really is), and the code is readable. Last night, I was able to take a few thousand lines of Linux Qt code written prior to Qt 2.0, and port it to Qt 3.3.5 for Windows in about 30 minutes. Last year, I ported a 15,000 line Qt application from Linux to Windows in about 16 hours, and I had never used Qt before. If that doesn’t attest to Qt’s quality, I don’t know what will. They’ve done a great job with Qt. I quite enjoy working with it. In fact, I like it so much, that I plan on using it for non-GUI C++ projects in the future. As of Qt 4, you don’t even need an event loop. Now that’s cool!