QSlider Value Changed Signal

Good question, I checked the API and also couldn’t find a signal that would be triggered only if value was modified by user. The workaround you proposed may be the only option, just keep in mind that you don’t have to disconnect / connect all signals, just use QObject::blockSignals method: slider->blockSignals(true); slider->setValue(x); slider->blockSignals(false); Hope that … Read more

Build Qt in “Release with Debug Info” mode?

Old question, I know. But nowadays, you can simply use CONFIG += force_debug_info to get debug symbols even in release mode. When you use QMake via the command line, I usually do this to get a release build with debug info: qmake CONFIG+=release CONFIG+=force_debug_info path/to/sources this will enable below conditions of Qt5/mkspecs/features/default_post.prf: force_debug_info|debug: CONFIG += … Read more

What is the signal for when a widget loses focus?

There’s no signal but if you want to know when your widget has lost focus, override and reimplement void QWidget::focusOutEvent(QFocusEvent* event) in your widget. It will be called whenever your widget has lost focus. To give focus to a widget, use QWidget::setFocus(Qt::FocusReason). To validate input in a QLineEdit or QComboBox you can subclass QValidator and … Read more

How to set selected filter on QFileDialog?

Like this: QString selfilter = tr(“JPEG (*.jpg *.jpeg)”); QString fileName = QFileDialog::getOpenFileName( this, title, directory, tr(“All files (*.*);;JPEG (*.jpg *.jpeg);;TIFF (*.tif)” ), &selfilter ); The docs are a bit vague about this, so I found this out via guessing.

How can I move file into Recycle Bin / trash on different platforms using PyQt4?

It’s a good thing you’re using Python, I created a library to do just that a while ago: http://www.hardcoded.net/articles/send-files-to-trash-on-all-platforms.htm On PyPI: Send2Trash Installation Using conda: conda install Send2Trash Using pip: pip install Send2Trash Usage Delete file or folders from send2trash import send2trash send2trash(“directory”)

switch/case statement in C++ with a QString type

You can, creating an QStringList before iteration, like this: QStringList myOptions; myOptions << “goLogin” << “goAway” << “goRegister”; /* goLogin = 0 goAway = 1 goRegister = 2 */ Then: switch(myOptions.indexOf(“goRegister”)){ case 0: // go to login… break; case 1: // go away… break; case 2: //Go to Register… break; default: … break; }

How do I remove trailing whitespace from a QString?

QString has two methods related to trimming whitespace: QString QString::trimmed() const Returns a string that has whitespace removed from the start and the end. QString QString::simplified() const Returns a string that has whitespace removed from the start and the end, and that has each sequence of internal whitespace replaced with a single space. If you … Read more