Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Exotic_Devel last edited by
From what I've been reading, Qt does not use exceptions. So what would be the way to capture errors from some Qt classes? For example QFile.
Operation that might fail in Qt are generally in the form of bool methodThatMightFail() so you would check whether the method is successful and if not check the error/errorString method. Some more advanced classes are using a dedicated error class like QSqlError.
Hope it helps
In most cases Qt uses error codes or other meaningful return values like null pointers. For example if file can't be opened for whatever reason QFile::open() will return false.
Often you can also query for the result of some operation. An example of that is "QNetworkReply::error()":http://qt-project.org/doc/qt-5/qnetworkreply.html#error
If an operation is in some sense detached from the point of invocation (eg. asynchronous) Qt also emits signals. An example of that is "QNetworkAccessManager::sslErrors":http://qt-project.org/doc/qt-5/qnetworkaccessmanager.html#sslErrors
In rare cases you can also pass an optional variable that will be filled with the result of an operation. An example of that is "QString::toInt()":http://qt-project.org/doc/qt-5/qstring.html#toInt
If unsure how specific class handles an error refer to the docs. They are usually clear about it.